polymer - 如何在 Polymer 1.0 中重新加载/刷新铁列表?

标签 polymer polymer-1.0

我已将一项添加到绑定(bind)到 iron-list 的数据属性中。 .

this.data.push(item); // add new item to array

现在数据项已添加,但列表不会刷新/重新加载以显示添加到数据数组的新项目。你如何重新加载铁名单?在 iron-list API page 上似乎也找不到方法.我尝试了以下但没有快乐......
var list = this.querySelector("iron-list");
list.fire('refresh');
list._refresh();

我的数据属性定义如下:
Polymer({
  is: "page-list",
  properties: {
    data: {
      type: Array,
      notify: true
    }

模板结构为:
<iron-ajax url="./data.json" last-response="{{data}}" auto></iron-ajax>
<iron-list items="[[data]]" as="item" class="fit">
  <template>
    <div class="row">
      <p>[[item.name]]</p>
    </div>
  </template>
</iron-list>

最佳答案

您将需要使用 Polymer 函数来添加新项目,如下所示 -

this.push('data', item);

Mutations to the items array itself (push, pop, splice, shift, unshift) must be performed using methods provided on Polymer elements, such that the changes are observable to any elements bound to the same array in the tree.



您可以从 here 了解更多信息.

关于polymer - 如何在 Polymer 1.0 中重新加载/刷新铁列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31999203/

相关文章:

html - 如何在自定义元素 (Polymer 1.0) 内设置纸张元素的样式?

javascript - 使用javascript更改聚合物1.0中纸张图标按钮的CSS样式

javascript - 单击 Polymer 中的按钮加载更多内容

javascript - 在 Sails.js 上添加 Polymer

javascript - 在 Polymer 1.0 中使用选项卡切换 View

javascript - 切换纸张按钮的禁用属性

javascript - polymer - 结束绑定(bind)事件时 dom-repeat?

Polymer 1.0 - 路由

polymer - Polymer 1.0 中是否使用了 content 元素?

polymer - 1.0 中的条件属性