我正在学习Polymer 1.8,并且试图从api获取数据。
之后,我想使用dom-repeate绑定ontap()函数中的数据,但是在控制台中出现了一个奇怪的错误:
[dom-repeat :: dom-repeat]:items
的期望数组,找到了[{“ requestnum”:“ 1045”,“ orgid”:“ EAGLENA”},{“ requestnum”:“ 1046”,“ orgid“:” EAGLENA“},{” requestnum“:” 1047“,” orgid“:” EAGLENA“},{” requestnum“:” 1048“,” orgid“:” EAGLENA“},{” requestnum“:” 1049“,” orgid“:” EAGLENA“}]
我无法解决此问题,有人可以帮助我吗?
此代码有什么问题????
我使用聚合物1.8
*这是我的html文件maximo-test-card.html:
<dom-module id="maximo-test-card">
<template>
<template is="dom-repeat" items="{{hi}}">
<li>
<span>{{item.requestnum}}</span>
</li>
</template>
<div>{{hi}}</div>
<iron-ajax
id="requestRepos"
headers='{"Content-Type": "application/json", "Accept": "someAccept", "Authorization": "someAuthorizationToken"}'
url="http://vaganet.vaganet.fr:9080/maximo/oslc/os/mxinvres?oslc.select=*"
handle-as="json"
on-response="ontap"> </iron-ajax> </template>
<script src="maximo-test-card.js"></script>
</dom-module>
*this is my js file maximo-test-card.js:
Polymer({
is: 'maximo-test-card',
properties: {
repos: {
type: Array
},
githubrepository:{
type: Array
},
hi:{
type: Array,
},
},
ready: function () {
this.$.requestRepos.generateRequest();
//console.log(hi)
//this.name=hi
},
ontap: function (data) {
this.repos = data.detail.response.member;
hi = []
for (var i = 0; i < 5; i++) {
hi[i] = {"requestnum":this.repos[i].requestnum,"orgid":this.repos[i].orgid}
}
this.hi = JSON.stringify(hi)
alert(this.hi);
return this.hi;
},
});