我将Engagespot SDK代码添加到我的index.html页面中。但是,我在登录页面上得到了这个错误。
Uncaught (in promise) TypeError: Cannot read property 'classList' of null
at t._showNotificationCenter (EngagespotSDK.2.0.js:1)
at EngagespotSDK.2.0.js:1发布于 2020-05-17 09:34:13
在SPA上安装Engagespot (如React、Vue等)有点不同,如本文中提到的- https://docs.engagespot.co/how-to-install-engagespot/how-to-set-up-engagespot-in-single-page-applications。
当脚本找不到您在帐户中配置的HTML元素(占位符元素)时,会发生上述错误。
通常,这种情况发生在具有登录屏幕的应用程序中。元素可能不存在于登录页面上,但仅存在于登录屏幕之后的页面上。
要解决这个问题,您需要使Engagespot.init()函数只在具有占位符元素的页面上执行。因此,您可以从index.html中的主要Engagespot SDK代码中删除此函数。并将其放置为占位符元素的挂载生命周期。
https://stackoverflow.com/questions/61848655
复制相似问题