Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ansible/3.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 阵列元件的聚合物1.0路径_Polymer - Fatal编程技术网

Polymer 阵列元件的聚合物1.0路径

Polymer 阵列元件的聚合物1.0路径,polymer,Polymer,简单的例子: <template is="dom-repeat" items="{{items}}"> <template is="dom-repeat" items="{{item.subitems}}"> <span>{{item}}</span> </template> <span on-tap="add">ADD</span> </template>

简单的例子:

<template is="dom-repeat" items="{{items}}">
    <template is="dom-repeat" items="{{item.subitems}}">
        <span>{{item}}</span>
    </template>
    <span on-tap="add">ADD</span>
</template>

attached: function () {
    this.items = [
        { subitems:[] },
        { subitems:[] }
    ]
},
add: function (e) {
    e.model.item.subitems.push("Test");
}

{{item}}
添加
附:函数(){
此项。项目=[
{子项:[]},
{子项:[]}
]
},
加:职能(e){
e、 模型.item.subitems.push(“测试”);
}
这不会刷新{{item.subitems}的dom重复。如何将更改通知polymer?

必须使用聚合物元素上提供的方法对项目数组本身(推送、弹出、拼接、移位、取消移位)进行突变,这样,树中绑定到同一数组的任何元素都可以观察到变化。例如:
this.push('employees',{first:'Jack',last:'Aubrey'})


我认为这只适用于将元素推送到项目,而不适用于子项目。有点不太正常,但我成功地做到了:
var arrayLoc=e.model.\uuuuuu key\uuuuu
var stringLoc=“items.”+arrayLoc+“.subitems”
this.push(stringLoc,“test”)很抱歉,我尝试了这个,但它不起作用:this.push(“item.subitems”,“Test”)。我认为可以使用元素的索引,如“items.3.subitems”,但必须有一种更简单的方法?经过一些测试后,我认为正确的方法是:e.model.push(“item.subitems”,“Test”)