聚合物不删除已删除的元素

Polymer not removing deleted element

使用 Polymer Stater Kit,我创建了两个自定义元素:

app.js文件中,我还定义了一个addElement函数

我可以将元素添加到 flowElementArray,它们会显示出来。

但是,当我从 flowElementArray 中删除元素时,它们仍然显示。

我是这样得到以下结果的:

  1. 应用启动(预加载 2 个项目)
  2. 我删除了一个项目(该项目留在屏幕上)
  3. 我加了一项(加了项,上面顺便删了一项)

这种奇怪行为的根源是什么?

编辑 我无法在 plunker/codepen 上制作示例 运行。io/jsbin 所以这里是 github .

我如何添加元素:

app.storageLoaded = function() {

  if (this.$.s1.value === '' || this.$.s2.value === '') {
    window.alert('One field is Empty!');
    return;
  }

  this.$.flowListID.push('flowDictionnary',
  {
    first: this.$.s1.value,
    last: this.$.s2.value
  });
};

我如何删除:

removeItem: function() {
  var counter = 0;
  while (counter < this.dict.length) {
    var item = this.dict[counter];
    if (item.first === this.name) {
      this.dict.splice(counter, 1);
    } else {
      counter++;
    }
  }
}

在Polymer中对数组属性进行操作时,需要使用this.push('myArrayProperty', item)this.splice('myArrayProperty', 0, 1)或在操作后调用this.notifyPath('myArrayProperty')

removeItem: function() {
  var counter = 0;
  while (counter < this.dict.length) {
    var item = this.dict[counter];
    if (item.first === this.name) {
      // this.dict.splice(counter, 1);
      this.splice('dict', counter, 1);
    } else {
      counter++;
    }
  }
}