【发布时间】:2017-04-07 03:23:47
【问题描述】:
我在 Backbone 上有一个网站。 当我尝试执行 Disqus 代码时,我得到了
未捕获的类型错误:无法读取 null 的属性“appendChild”
我该如何解决?为什么会这样?
var disqus_shortname = 'mysite';
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
控制台:
undefined
embed.js:1 Unsafe attempt to redefine existing module: BASE
embed.js:1 Unsafe attempt to redefine existing module: apps
embed.js:1 Unsafe attempt to redefine existing module: get
...
embed.js:1 Unsafe attempt to redefine existing module: configAdapter
embed.js:1 Unsafe attempt to redefine existing module: removeDisqusLink
embed.js:1 Unsafe attempt to redefine existing module: loadEmbed
embed.js:1 Unsafe attempt to redefine existing module: reset
embed.js:1 Uncaught TypeError: Cannot read property 'appendChild' of null
【问题讨论】:
-
似乎您没有在 HTML 中定义 head 或 body 标记。
标签: javascript backbone.js disqus