Uncaught TypeError: systems[e] is not a constructor when loading A-Frame dynamically
Uncaught TypeError: systems[e] is not a constructor when loading A-Frame dynamically
我正在尝试通过 Javascript 将 A-Frame 附加到头部来动态加载 A-Frame,如下所示:
var script_af = document.createElement('script');
script_af.type = 'text/javascript';
script_af.onload = function(){
//create the scene elements and etc
}
script_af.src = 'https://aframe.io/releases/1.2.0/aframe.min.js';
document.head.appendChild(script_af);
这种方法适用于其他脚本,但由于某种原因我使用 aframe 时出现以下错误:
Uncaught TypeError: systems[e] is not a constructor
at HTMLElement.initSystem (a-scene.js:195)
at HTMLElement.initSystems (a-scene.js:180)
at HTMLElement.value (a-scene.js:137)
at HTMLElement.attachedCallback (a-register-element.js:160)
at m (document-register-element.js:2)
at l (document-register-element.js:2)
at HTMLDocument.r.<computed> [as registerElement] (document-register-element.js:2)
at module.exports.registerElement (a-register-element.js:69)
at Object.116.../../lib/three (a-scene.js:39)
at o (_prelude.js:1)
如果我将脚本标签直接添加到头部并像往常一样动态加载场景的其余部分,它就可以正常工作。
为什么我会收到这个错误,有没有办法解决这个问题?
原来我体内有一个剩余的 aframe 标签,我还没有删除它,不知何故导致了问题,一旦删除它就可以正常工作。
我正在尝试通过 Javascript 将 A-Frame 附加到头部来动态加载 A-Frame,如下所示:
var script_af = document.createElement('script');
script_af.type = 'text/javascript';
script_af.onload = function(){
//create the scene elements and etc
}
script_af.src = 'https://aframe.io/releases/1.2.0/aframe.min.js';
document.head.appendChild(script_af);
这种方法适用于其他脚本,但由于某种原因我使用 aframe 时出现以下错误:
Uncaught TypeError: systems[e] is not a constructor
at HTMLElement.initSystem (a-scene.js:195)
at HTMLElement.initSystems (a-scene.js:180)
at HTMLElement.value (a-scene.js:137)
at HTMLElement.attachedCallback (a-register-element.js:160)
at m (document-register-element.js:2)
at l (document-register-element.js:2)
at HTMLDocument.r.<computed> [as registerElement] (document-register-element.js:2)
at module.exports.registerElement (a-register-element.js:69)
at Object.116.../../lib/three (a-scene.js:39)
at o (_prelude.js:1)
如果我将脚本标签直接添加到头部并像往常一样动态加载场景的其余部分,它就可以正常工作。
为什么我会收到这个错误,有没有办法解决这个问题?
原来我体内有一个剩余的 aframe 标签,我还没有删除它,不知何故导致了问题,一旦删除它就可以正常工作。