【发布时间】:2016-10-02 10:57:23
【问题描述】:
我是使用 iron-ajax 的用户 iron-list,但在将元素推送到 iron-list 时出现 ajax 响应后给出 null 异常 =“无法读取未定义的属性 '_list'”
<script>
Polymer({
is: 'my-home',
ready: function () {
this.$._ajax.generateRequest();
},
onResponse: function (e) {
var people = e.detail.response.data;
people.forEach(function (person) {
this.$._list.push('items', person);
});
// Clear the lower threshold so we can load more data when the user scrolls down again.
this._scrollTheshold.clearTriggers();
}
});
</script>
这是我的 Iron-list 的 html 代码
<iron-list id="_list" items="[[data.data]]" as="item">
<template>
<div style="margin-top: 0px">
<!--Card with header image http://placehold.it/350x150/FFC107/000000-->
<paper-card>
<div class="card-content">
<h1 class="feed_title">[[item.heading]]</h1>
<p class="feed_description">[[item.subheading]]</p>
</div>
<div class="card-actions">
<paper-button class="button-blue">
Share
</paper-button>
<paper-button class="button-blue">
Explore
</paper-button>
</div>
</paper-card>
</div>
</template>
</iron-list>
【问题讨论】:
-
我认为
this不是你想的那样:)。试试这个问题的建议:stackoverflow.com/questions/346015/javascript-closures-and-this
标签: polymer progressive-web-apps