<dom-module id="name-tag">
<template>
<div id="offices-list"></div>
</template>
<script>
Polymer({
is: "name-tag",
ready: function() {
var div_new = document.createElement('div');
Polymer.dom(this.$.officesList).appendChild(div_new);
}
});
</script>
</dom-module>
目前出现错误:
Uncaught HierarchyRequestError:无法执行&#39; appendChild&#39;上 节点&#39;:只允许文档中的一个元素。
但是,如果我更改了&#34; offices-list&#34; to&#34; officesList&#34;,它的工作原理。我怎样才能保持id的原样,即用破折号?
答案 0 :(得分:8)
这是一个开放的问题/增强聚合物:
https://github.com/Polymer/polymer/issues/1747也https://github.com/Polymer/polymer/issues/150
解决方法是使用this.$['offices-list']