更新了URL,但是subject是obejct,没有数据

来源:20-14 电影页面数据绑定(下)

森林迷了鹿Andera

2018-06-06

var app = getApp();


// pages/movies/movies.js

Page({


onLoad: function (options) {


var gloabalBase = app.globalData.douBanBase;


var inTheatersURL = gloabalBase + "/v2/movie/in_theaters" +"?start=0&count=3";

var commningSoonURL = gloabalBase + "/v2/movie/coming_soon" + "?start=0&count=3";

var topURL = gloabalBase + "/v2/movie/top250" + "?start=0&count=3";


this.getMovieListData(inTheatersURL);

// this.getMovieListData(commningSoonURL);

// this.getMovieListData(topURL);


},

getMovieListData:function(url){

var that = this;


wx.request({

url:url ,

method: 'GET',

header: {

'Content-Type': 'json'

},

success: function (res) {

console.log(res.data);

that.processMovieData(res.data);

}


});


},


processMovieData:function(movieData){


var movies = [];

for(var item in movieData.subjects){

var subject = movieData.subjects[item];

var title = subject.title;

if(title.length >6){

title = title.substring(0,6)+"...";

}

var temp = {

title:title,

id:subject.id,

img: subject.images.large,

average: subject.rating.average

}

movies.push(temp);

}

this.setData({

movies : movies

});


console.log("movies:"+movies);

}

})


写回答

1回答

kekestudy

2018-06-18

doubanBase:"https://douban.uieee.com"


0
0

微信小程序入门与实战(全新版) 超20000人学习的好课

4年同步微信官方迭代,累计20000+人学习, 比微信官方更火爆!

23867 学习 · 6899 问题

查看课程