Javascript Can';t从字典中删除元素
在我前面的问题之后:,我需要从字典中删除一个元素,当我在另一个自定义元素中导入此自定义元素时,该元素作为属性传递 流量元件Javascript Can';t从字典中删除元素,javascript,dictionary,polymer,Javascript,Dictionary,Polymer,在我前面的问题之后:,我需要从字典中删除一个元素,当我在另一个自定义元素中导入此自定义元素时,该元素作为属性传递 流量元件 <script> Polymer({ is: 'flow-element', properties: { dict: { type: String, notify: true }, name: { type: String }, kind: { type: Strin
<script>
Polymer({
is: 'flow-element',
properties: {
dict: {
type: String,
notify: true
},
name: {
type: String
},
kind: {
type: String
}
},
handleClick: function() {
console.log('clicked: ' + this.name);
// the output does work
console.log('Dict before ::' + JSON.stringify(this.dict, null, 4));
// this does NOT work
delete this.dict[this.name];
// the output does work, but dictionary is unchanged
console.log('Dict after ::' + JSON.stringify(this.dict, null, 4));
}
});
</script>
<flow-element dict={{flowDictionnary}} name="{{item.first}}" kind="{{item.last}}"></flow-element>
之后
但是,显示dictionary元素的列表不会更新,元素将保留在屏幕上。您已尝试使用此.splice(path,start,deleteCount)?
您必须按如下方式使用它:
this.拼接(“dict”,索引,1)
其中索引
指要移除的元件的位置。
有关推送、弹出、拼接和其他聚合物有用功能的更多信息。非常感谢。。。我还有一个问题:
{
"first": "Bob",
"last": "Smith"
}
{
"first": "Sally",
"last": "Johnson"
}
null,
{
"first": "Sally",
"last": "Johnson"
}