Javascript 为什么不能创建具有多个子节点的ParentNode?
我有以下带有A框架的html结构。基本上,我正在使用以下基本html构建atom的3D表示:\Javascript 为什么不能创建具有多个子节点的ParentNode?,javascript,jquery,html,aframe,Javascript,Jquery,Html,Aframe,我有以下带有A框架的html结构。基本上,我正在使用以下基本html构建atom的3D表示:\ <a-scene> <a-entity id=#AtomComponent> <a-sphere id=#nucleus></a-sphere> <a-entity id=#electronShell> <a-sphere id=#electron></a-sphe
<a-scene>
<a-entity id=#AtomComponent>
<a-sphere id=#nucleus></a-sphere>
<a-entity id=#electronShell>
<a-sphere id=#electron></a-sphere>
</a-entity>
</a-entity>
</a-scene>
也许我累了,但我相信我正在以正确的顺序创建html元素。但是,当我尝试执行此代码时,我收到以下两个错误:
material.js:170 Uncaught TypeError: Cannot read property 'dispose' of undefined
`Uncaught (in promise) TypeError: Cannot read property 'isPlaying' of null`
有人能再检查一下我的html是否合法吗
AtomComponent
应该有两个孩子(nucleus
和electronShell
),而electronShell
只有一个孩子。由于我是A-Frame新手,对javascript已经不熟悉,所以我无法确定这是一个A-Frame级别的错误还是一个JS选择器错误。非常感谢您的帮助。使用atomComponent.appendChild
附加nucleus
和electronShell
以拥有多个孩子
let sceneEl=document.querySelector('a-scene');
让atomComponent=document.createElement('a-entity');
让nucleus=document.createElement('a-sphere');
让electronShell=document.createElement('a-entity');
让electron=document.createElement('a-sphere');
sceneEl.appendChild(原子组件);
原子成分。附子(核);
原子元件。附加元件(electronShell);
electronShell.appendChild(电子);
console.log(document.querySelector('a-scene').outerHTML)代码>
“AtomComponent
应该有两个孩子(nucleus
和electronShell
)”用AtomComponent.appendChild(electronShell)
代替electronShell.appendChild(AtomComponent)
,谢谢!我想我有点累了,因为没有看到那个。
material.js:170 Uncaught TypeError: Cannot read property 'dispose' of undefined
`Uncaught (in promise) TypeError: Cannot read property 'isPlaying' of null`