Polymer 嵌套dom repeat的挑战&;对象/数组组合

Polymer 嵌套dom repeat的挑战&;对象/数组组合,polymer,Polymer,我在操作对象/数组组合时遇到了一些问题&在嵌套的dom重复中反映更改。这是可行的,但感觉像是一个黑客的方法-谁能告诉我,如果有更好的方法 (仅限铬) 请参阅itemTap函数了解黑客行为的具体区域。或者也许有更好的方法来解决这个问题?这样做 itemTap: function(e) { e.model.set('i.container.value', e.model.i.container.value + ' tapped'); }, 而不是 itemTap: functi

我在操作对象/数组组合时遇到了一些问题&在嵌套的dom重复中反映更改。这是可行的,但感觉像是一个黑客的方法-谁能告诉我,如果有更好的方法

(仅限铬)

请参阅itemTap函数了解黑客行为的具体区域。或者也许有更好的方法来解决这个问题?

这样做

  itemTap: function(e) {
    e.model.set('i.container.value', e.model.i.container.value + ' tapped');
  },
而不是

  itemTap: function(e) {
    //This is an overly complicated way to update a "container.value" in the items object arrays no?!

    e.model.set('i.container.value', e.model.i.container.value + ' tapped');

    var array = this.items[e.model.cat];
    array[e.model.index].container.value += ' tapped';

    this.set(['items', e.model.cat], []);
    this.async(function(){this.set(['items', e.model.cat], array);});
  },
Fwiw,你也可以

    this.items = {
      'One':  [{container:{value: '1a'}}, {container:{value: '1b'}}],
      'Two':  [{container:{value: '2a'}}, {container:{value: '2b'}}],
      'Three':[{container:{value: '3a'}}, {container:{value: '3b'}}]
     });
而不是

    this.set(['items', 'One'], [{container:{value:'1a'}}, {container:{value:'1b'}}]);
    this.set(['items', 'Two'], [{container:{value:'2a'}}, {container:{value:'2b'}}]);
    this.set(['items', 'Three'], [{container:{value:'3a'}}, {container:{value:'3b'}}]);

   this.categories = ['One', 'Two', 'Three'];

您最初是否将该值设置为空数组,然后返回到原始数组(已更新),以强制dom repeat重新绘制?如果是这样的话,我想你正在吃。谢谢!我可以发誓我已经试过了,不过现在确实奏效了:)其他的几点也很好。