Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Polymer 不显示动态添加的值_Polymer_Dom Repeat - Fatal编程技术网

Polymer 不显示动态添加的值

Polymer 不显示动态添加的值,polymer,dom-repeat,Polymer,Dom Repeat,Polymer dom repeat未按预期工作,当我向数组动态添加新元素时,dom repeat未显示该值 我在将物品推入阵列时使用聚合物的阵列突变方法,但仍然不起作用 请检查代码笔链接 <dom-module id="wind-studio-widget"> <template> <div on-tap='_addNewPad' style="cursor:pointer"><strong>Click Me</stro

Polymer dom repeat未按预期工作,当我向数组动态添加新元素时,dom repeat未显示该值


我在将物品推入阵列时使用聚合物的阵列突变方法,但仍然不起作用

请检查代码笔链接

    <dom-module id="wind-studio-widget">
  <template>
    <div on-tap='_addNewPad' style="cursor:pointer"><strong>Click Me</strong></div>
  <template id="padListContainerId" is="dom-repeat" items="[[padList]]">
    <p style="border:1px solid red">&nbsp;<span>[[item.id]]</span></p>
  </template>
  </template>
</dom-module>
<script type="text/javascript">
    Polymer({

        is: 'wind-studio-widget',

        properties: {
            baseUrl: {type: String},
            padList: {
                type: Array,
                notify: true
            },
            padListAverage: {type: Object}
        },

        ready: function () {
            //this.baseUrl = localStorage.baseUrl;
            //this.loadPadData();
          this.padList = [{'id':'1'},{'id':'2'}];
        },

        _addNewPad: function () {
            var newPadList = this.padList;
            newPadList.push({'id':'3'});
            this.set('padList', []);
            this.set('padList', newPadList);
            console.log(this.padList);
          //this.$.padListContainerId.render();
        }
    });
  </script>

单击我

[[item.id]]

聚合物({ 是:“wind studio widget”, 特性:{ baseUrl:{type:String}, 名单:{ 类型:数组, 通知:正确 }, padListAverage:{type:Object} }, 就绪:函数(){ //this.baseUrl=localStorage.baseUrl; //这是loadPadData(); this.padList=[{'id':'1'},{'id':'2'}]; }, _addNewPad:函数(){ var newPadList=this.padList; push({'id':'3'}); 此.set('padList',[]); 此.set('padList',newPadList); console.log(this.padList); //这是$.padListContainerId.render(); } });

在将项目推入数组时,我正在使用Polymer的数组变异方法,但值仍然没有显示在dom重复模板中。使用Polymer的数组变异方法将是
this.push('padlist',{id':'3'))
谢谢Maria,它现在正在工作。我已经更新了代码笔中的代码;在将项目推入数组时,我正在使用Polymer的数组变异方法,但值仍然没有显示在dom重复模板中。使用Polymer的数组变异方法将是
this.push('padlist',{id':'3')
谢谢Maria,它现在正在工作。我已经更新了代码笔中的代码;