确报了一大串警告,看着这警告很烦,这个问题怎么解决?图片:
代码:
components代码
// components/indexmodule/indexmodule.ts
Component({
properties: {
items:{
type:Array,
value:[]
},
},
<!--components/indexmodule/indexmodule.wxml-->
<scroll-view class="module-scroll-view" scroll-x="{{true}}">
<itemview wx:for="{{items}}" wx:key="title"></itemview>
</scroll-view>
pages页面代码
<!--index.wxml-->
<indexmodule items="{{movies}}"></indexmodule>
// index.ts
onLoad() {
var that = this;
network.getMovieList({
success:function(movies:any){
that.setData({
movies:movies
})
}
})
}
// /utils/urls。ts
getMovieList: function (params: any) {
params.type = "movie";
this.getItemList(params);
},
getItemList: function (params: any) {
var url = "";
if (params.type === 'movie') {
url = globalUrls.movieList;
} else if (params.type === 'tv') {
url = globalUrls.tvList;
} else {
url = globalUrls.showList;
}
var count = params.count ? params.count:7;
wx.request({
url: url,
data: {
count: count,
},
success: function (res: any) {
// console.log(res);
var items = res.data.subject_collection_items;
var itemsCount = items.length;
var left = itemsCount%3;
if(left === 2){
items.push(null)
}
if (params && params.success) {
params.success(items);
}
}
})
}
你看你的items是个数组吗?