【问题标题】:In polymer 1.0 Importing polymer-button in a custom element gives error在聚合物 1.0 中,在自定义元素中导入聚合物按钮会出错
【发布时间】:2015-07-30 07:12:17
【问题描述】:

我编写了一个简单的 Polymer 自定义元素,并希望在其中使用 paper-button 元素。我的代码如下所示:

<link rel="import" href="bower_components/Polymer/polymer.html">
<link rel="import" href="bower_components/paper-button/paper-button.html">

<dom-module id='chart-label'>
  <template is="dom-bind">
    <template is="dom-repeat" items="{{lables}}">
      <input type=checkbox checked="true" id="checkb" value={{item}} name="check" on-change="checkChanged"><b>{{item}}</b>
      </template>
  </template>
  <script>
    Polymer({
      is: 'chart-label',
      buttonStates: [],
      properties: {
        buttonstates: {
          type: Array,
          value: [],
          notify: true,
        },
        lables:Array
      },
      ready: function () {
        for (var i = 0; i < this.lables.length; i++) {
          this.buttonstates.push(true);
        }
      },
      checkChanged: function (e) {
        var it = e.model.item;
        var index = this.lables.indexOf(it);

        console.log(index + " index checked");
        if (e.target.checked) {
          this.buttonstates[index] = true;
        } else {
          this.buttonstates[index] = false;
        }

//      for (var i = 0; i < this.lables.length; i++)  {
//        alert(this.buttonstates[i]);
//      }

        //console.log("this.buttonstates"+this.buttonstates);
        this.fire('checked',this.buttonstates);
      }
    });
  </script>
</dom-module>

当我尝试测试此代码时,它失败并出现以下错误:

未捕获的 NotSupportedError:无法在“文档”上执行“registerElement”:“dom-module”类型的注册失败。已注册具有该名称的类型。

我在这里错过了什么?

注意我在 Polymer 1.0 上编写此代码 **

【问题讨论】:

    标签: javascript polymer-1.0 paper-elements


    【解决方案1】:

    我弄乱了代码中的聚合物版本。我在一起构建新应用程序后修复了它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多