我是Polymer的新手,我试图使用iron-ajax元素循环API响应,而且我遇到了麻烦。我得到的错误是:polymer-micro.html:260 [dom-repeat::dom-repeat]: expected array for
项, found Object
这就是我正在使用的:
<dom-module id="untappd-data">
<template>
<style>
:host {
display: block;
box-sizing: border-box;
}
</style>
<iron-ajax
auto
url="https://api.untappd.com/v4/user/checkins/jimouk?client_id=[hidden]&client_secret=[hidden]"
handle-as="json"
last-response="{{response}}"></iron-ajax>
<template is="dom-repeat" items="{{response.response.checkins}}">
{{item.name}}
</template>
</template>
</dom-module>
<script>
Polymer({
is: 'untappd-data',
properties: {
owner: {
value: 'polymer',
notify: true
},
url: {
computer: 'computeUrl(owner)'
}
}
});
</script>
据我所知,dom-repeater元素只在数组上循环,但我想知道是否有某种方法我应该使用Polymer,而不是将所有这些对象移动到使用传统Javascript的数组中。