我是ReactJS的新手。我使用ReactJS & NextJs开发了一个登陆页面/静态网站。现在我正在尝试集成一个聊天机器人‘漂移’。在安装过程中,他们说要安装,我必须在<head>文件中插入<head>代码。我找到了我的react应用程序自动创建的html文件,并插入了这段代码,但什么也没有发生。
<script>
"use strict";
!function() {
var t = window.driftt = window.drift = window.driftt || [];
if (!t.init) {
if (t.invoked) return void (window.console && console.error && console.error("Drift snippet included twice."));
t.invoked = !0, t.methods = [ "identify", "config", "track", "reset", "debug", "show", "ping", "page", "hide", "off", "on" ],
t.factory = function(e) {
return function() {
var n = Array.prototype.slice.call(arguments);
return n.unshift(e), t.push(n), t;
};
}, t.methods.forEach(function(e) {
t[e] = t.factory(e);
}), t.load = function(t) {
var e = 3e5, n = Math.ceil(new Date() / e) * e, o = document.createElement("script");
o.type = "text/javascript", o.async = !0, o.crossorigin = "anonymous", o.src = "https://js.driftt.com/include/" + n + "/" + t + ".js";
var i = document.getElementsByTagName("script")[0];
i.parentNode.insertBefore(o, i);
};
}
}();
drift.SNIPPET_VERSION = '0.3.1';
drift.load('xxxxxxxx');
</script>
<!-- End of Async Drift Code --> 当我在本地主机上查看登陆页面时,我在<header>中找不到这个脚本
发布于 2020-04-22 18:30:28
我使用npm i react-drifts解决了这个问题,然后将Drift导入到我的react应用程序中。然后我用了<Drift appId='xxxx'/>。appId嵌入到javascript脚本drift.load('xxxxxxxx')中,该脚本允许您添加<head/>
https://stackoverflow.com/questions/61367550
复制相似问题