我是飞镖和聚合物的初学者.当我在Chrome中运行网络应用时,我得到:
Uncaught HierarchyRequestError: Failed to execute 'appendChild' on 'Node': Nodes of type 'HTML' may not be inserted inside nodes of type '#document'. patches-mdv.js:57
(anonymous function) patches-mdv.js:57
(anonymous function) patches-mdv.js:57
(anonymous function) patches-mdv.js:57
Run Code Online (Sandbox Code Playgroud)
appendChild可能是生成的dart2js代码,即下面的部分:
Node: {
"^": "EventTarget;ownerDocument=,text:textContent=",
remove$0: function(receiver) {
var t1 = receiver.parentNode;
if (t1 != null)
J._removeChild$1$x(t1, receiver);
},
toString$0: function(receiver) {
var t1 = receiver.nodeValue;
return t1 == null ? J.Interceptor.prototype.toString$0.call(this, receiver) : t1;
},
append$1: function(receiver, newChild) {
return receiver.appendChild(newChild);
},
insertBefore$2: function(receiver, newChild, refChild) {
return receiver.insertBefore(newChild, refChild);
},
_removeChild$1: function(receiver, oldChild) {
return receiver.removeChild(oldChild);
},
_replaceChild$2: function(receiver, newChild, oldChild) {
return receiver.replaceChild(newChild, oldChild);
},
$isNode: true,
"%": "DocumentType|Notation;Node"
},
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
如https://groups.google.com/a/dartlang.org/forum/#!msg/web/bgMajiu_iR4/rygd5Ftk668J所述,根据症状,看起来platform.js已加载两次.
因此,除了你的toplevel index.html之外,从每个html中删除以下两行:
<script src="packages/web_components/platform.js"></script>
<script src="packages/web_components/dart_support.js"></script>
Run Code Online (Sandbox Code Playgroud)
更新:聚合物> platform.js
不再需要0.14.0 .它由pub build
和自动添加pub serve
.