Polymer Uncaught DOMException

时间:2018-04-20 12:43:30

标签: javascript polymer polymer-2.x

我在Polymer 2中有一个简单的todo aap。它工作得很好但是当我从Polymer目录中添加元素时,我得到以下错误?而且纸张输入也没有正确显示?检查屏幕截图。一切都很完美我不知道为什么会突然发生这种情况?

dom-module.html:136未捕获DOMException:无法执行'定义' on' CustomElementRegistry':此名称已用于此注册表     在http://127.0.0.1:8000/components/polymer-todo/bower_components/polymer/lib/elements/dom-module.html:136:18     在http://127.0.0.1:8000/components/polymer-todo/bower_components/polymer/lib/elements/dom-module.html:140:3

我的代码很简单

<link rel="import" href="../polymer/polymer-element.html">
<link rel="import" href="../polymer/lib/elements/dom-repeat.html">

<link rel="import" href="bower_components/paper-checkbox/paper-checkbox.html">
<link rel="import" href="bower_components/paper-input/paper-input.html">



<dom-module id="polymer-todo">
  <template>
   <h3>Todo:</h3>
   <dom-repeat
      items="{{tasks}}"
      as="task">
      <template>
        <div>

          <paper-checkbox ></paper-checkbox>


          <paper-input value="{{task}}"></paper-input>

        </div>
      </template>
   </dom-repeat>





    <button>Add task</button>
  </template>

  <script>
    /**
     * `polymer-todo`
     * Simple to do to add Todos
     *
     * @customElement
     * @polymer
     * @demo demo/index.html
     */
    class PolymerTodo extends Polymer.Element {
      static get is() { return 'polymer-todo'; }
      static get properties() {
        return {
          tasks: {
            type: Array,
            value: () => [1, 2, 3, 4, 5]
            }
        };
      }
    }

    window.customElements.define(PolymerTodo.is, PolymerTodo);
  </script>
</dom-module>

enter image description here

1 个答案:

答案 0 :(得分:0)

我修复了它。其实我改变了

<link rel="import" href="bower_components/paper-checkbox/paper-checkbox.html">

等到

<link rel="import" href="../paper-checkbox/paper-checkbox.html">

它奏效了。