这是报错的提示
movies is not defined;at "pages/movies/movies" page processDouBanData function
ReferenceError: movies is not defined
这是代码
var app=getApp();
Page({
data: {
},
onLoad: function () {
var top250Url=app.globalData.url+'/v2/movie/top250?start=0&count=3';
var inTheatersUrl=app.globalData.url+'/v2/movie/in_theaters?start=0&count=3';
var comingSoonUrl=app.globalData.url+'/v2/movie/coming_soon?start=0&count=3';
this.getMoviesData(top250Url);
// this.getMoviesData(inTheatersUrl);
// this.getMoviesData(comingSoonUrl);
},
getMoviesData: function (url) {
var that = this;
wx.request({
url: url,
data: {},
method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
header: {
"Content-Type": "json"
}, // 设置请求的 header
success: function (res) {
// success
that.processDouBanData(res.data);
},
fail: function (res) {
// fail
},
complete: function (res) {
// complete
}
})
},
processDouBanData:function(data){
//console.log(data);
var moives=[];
for(var idx in data.subjects){
var subject=data.subjects[idx];
var title=subject.title;
if(title.length>=6){
title=title.substring(0,6)+"...";
}
var temp={
title:title,
large:subject.images.large,
movieId:subject.id
}
moives.push(temp);
}
console.log(moives);// 这里 已经取到值了
this.setData({
movies:movies
})
}
})
这里的movies 老是报错 找了好久 还是找不出问题错在哪里了
4年同步微信官方迭代,累计20000+人学习, 比微信官方更火爆!
了解课程