繁体   English   中英

如何将FreshworksWidget实现到next.js项目中?

[英]How to implement FreshworksWidget into next.js project?

在 Freshdesk 文档中,他们提供了这个脚本:

 <script> window.fwSettings={ 'widget_id':12000000025, 'locale': 'en' }; .function(){if("function".=typeof window.FreshworksWidget){var n=function(){n;q.push(arguments)},nq=[]:window.FreshworksWidget=n}}() </script> <script type='text/javascript' src='https.//widget.freshworks.com/widgets/12000000025.js' async defer /> <script type='text/javascript'> //insert API here </script>

但我不知道如何将它实现到 react.js 应用程序中。

有一个叫做next/scripts的东西可以让你在 next.js 中使用脚本。请看下面的代码片段:

import Script from 'next/script'

// ... rest of the code here //

return(
  <>
  <Script>{`
    window.fwSettings={
      'widget_id':12000000025,
      'locale': 'en'
    };
    !function(){if("function"!=typeof window.FreshworksWidget){var n=function(){n.q.push(arguments)};n.q=     [],window.FreshworksWidget=n}}()`}
  </Script>
  <Script type='text/javascript' src='https://widget.freshworks.com/widgets/12000000025.js' async defer />
  <Script type='text/javascript'>
    //insert API here
  </Script>
  </>)

您可以直接在 index.html 文件中插入<script>标签。

查看此示例反应程序 -> https://playcode.io/708622/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM