请帮帮我!数据未显示在重复模板中。谢谢!
<link rel="import" href="bower_components/polymer/polymer.html">
<link rel="import" href="bower_components/iron-ajax/iron-ajax.html">
<dom-module id="list-binding">
<style></style>
<template is="dom-bind">
<iron-ajax
auto
url="data.json"
handle-as="json"
last-response="{{data}}">
</iron-ajax>
<!--Binding from API-->
<div class="list">
<template is="dom-repeat" items="{{data}}">
<paper-icon-item class="listItems">
<img class="avatar blue" item-icon src="{{item.image}}">
<paper-item-body two-line>
<div class="title">{{item.title}}</div>
<div secondary>{{item.description}}</div>
</paper-item-body>
</paper-icon-item>
</template>
</div>
<script>
Polymer({
is: "list-binding"
});
</script>
</dom-module
答案 0 :(得分:0)
聚合物的dom-repeat采用项目和索引。看起来您在示例中缺少索引。这是一个适合你的例子。
<dom-module id="my-component">
<template>
<iron-ajax
auto
url="{{url}}"
on-response="_dataResponse"
</iron-ajax>
<template is="dom-repeat" items="{{data}}" as="item">
<paper-icon-item class="listItems">
<img class="avatar blue" item-icon src="{{item.image}}">
<paper-item-body two-line>
<div class="title">{{item.title}}</div>
<div secondary>{{item.description}}</div>
</paper-item-body>
</paper-icon-item>
</template>
</template>
</dom-module>
<script>
Polymer({
is: 'my-component',
properties: {
data: Object
},
_dataResponse: function(e, detail){
this.data = detail;
}
});
</script>
&#13;