我已将一项添加到绑定(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/