我有一个像下面这样的聚合物特性。
gamma:{type:Array,observe:true,notify:true,value: [{"id":1,"value":["w"]}, {"id":2,"value":["w "]}]}
我正在使用此属性使用 div 在模板中显示行和列。
<template is="dom-repeat" items="{{gamma}}" id="maindiv">
<div class="layout__row">
<template is="dom-repeat" items="{{item.value}}">
<div class="layout__block" id$="{{item}}">
<button class="btn btn--primary margins">Add {{item}} Button</button>
</div>
</template>
</div>
</template>
如果我修改 gamma 属性以在第一个对象中添加一个值,并调用 notifysplices,它不会根据数字呈现 div。我正在从添加列方法调用渲染函数。
我有另一种称为 addrows 的方法,它具有此代码。
addRows: function(){
this.push("gamma", {"id":this.rows.length+1,"value": ["w"]} );
this.$.maindiv.render();
this.$.rowdiv.render();
}
我在这里缺少什么。
我找到了解决方案,子属性或嵌套数组更改应如下所示。
this.push(["gamma", i, "value"], "a");
来自 polymer.slack.com 的功劳归于 Arthur Evans