Aframe A框架拆下回路内部的部件
我有一个类似于下面代码的html模板Aframe A框架拆下回路内部的部件,aframe,Aframe,我有一个类似于下面代码的html模板 <a-entity id="id1"> <a-entity template="src: t1.template;type:nunjucks"> </a-entity> </a-entity> t1.template <a-entity id="id2"> {% for i in 4 %} <a-entity template="src: t2.temp
<a-entity id="id1">
<a-entity template="src: t1.template;type:nunjucks">
</a-entity>
</a-entity>
t1.template
<a-entity id="id2">
{% for i in 4 %}
<a-entity template="src: t2.template; type: nunjucks"></a-entity>
{% endfor %}
</a-entity>
t2.template
<a-entity id="id3" myComponent="x:4">
<a-entity>...
<a-entity>...</a-entity>
</a-entity>
<a-entity>
所有元素都被完美捕捉。但从父节点删除子节点时出错。
请有人帮我把它弄好。“提前感谢”看起来像是一个框架附加删除处理程序的问题。我不知道升级到0.5.0是否有用。使用未统一的版本可以精确追踪错误行吗?我在新版本中也遇到了错误。用版本0.5.0和未统一版本的错误更新了我的问题
AFRAME.registerComponent('myComponent', {
schema: {
x: {type: 'number', default: 0}
},
update: function () {
//set some attribute for entities inside id3
//adding event listener to id3.
this.el.addEventListener('click', function () {
setTimeout(function () {
var categoryEl = scene.querySelectorAll('#id3');
totalCategory = categoryEl.length;
for(i=0;i<totalCategory;i++){
categoryEl[i].removeAttribute('myComponent');
removeAttributeCount++;
}
}, 1500);
});
},
remove: function () {
//To check whether component is removed from all element
if(removeAttributeCount == totalCategory){
var id1 = this.el.sceneEl.querySelector('#id1');
id1.parentNode.removeChild(id1);
}
}
});
Uncaught TypeError: Cannot convert undefined or null to object
at NewComponent.remove (https://cdn.rawgit.com/donmccurdy/aframe-extras/v3.2.7/dist/aframe-extras.js:4742:16)
at HTMLElement.value (https://aframe.io/releases/0.5.0/aframe.js:71889:17)
at bound (https://aframe.io/releases/0.5.0/aframe.js:76993:17)
at Array.forEach (native)
at HTMLElement.value (https://aframe.io/releases/0.5.0/aframe.js:71567:36)
at NewComponent.remove (http://localhost:63342/myProj1HTML/Shop/ShopTrail-1/index.js:91:32)
at HTMLElement.value (https://aframe.io/releases/0.5.0/aframe.js:71889:17)
at HTMLElement.value (https://aframe.io/releases/0.5.0/aframe.js:71970:16)
at HTMLElement.value (https://aframe.io/releases/0.5.0/aframe.js:72095:14)
at HTMLElement.value (https://aframe.io/releases/0.5.0/aframe.js:72015:14)