电影页面绑定数据
来源:20-15 星星评分组件的实现
 
			芷1
2018-12-28
我在设置电影页面绑定的时候 data{}中我并没有设置初始值,但是也没有报错,绑定成功了,但是老师在视频里示范的出掉data{}中设置的初始值绑定,系统就报错了,是怎么回事,是小程序版本更新的问题吗
3回答
- 
				  芷1 提问者 2018-12-29 <import src="movie-list/movie-list-template.wxml" /> <view class='container'> <view class='movies-template'> <template is="movieListTemplate" data="{{...inTheaters}}"/> </view> <view class='movies-template'> <template is="movieListTemplate" data="{{...top250}}" /> </view> <view class='movies-template'> <template is="movieListTemplate" data="{{...comingSoon}}" /> </view> </view> 00
- 
				  芷1 提问者 2018-12-29 var app = getApp();//获取全局变量 app.js内部数据 Page({ data: { }, onLoad: function (options) { var inTheatersUrl = app.globalData.doubanBase +"/v2/movie/in_theaters"+"?start0&count=3"; var comingSoonUrl = app.globalData.doubanBase + "/v2/movie/coming_soon" + "?start0&count=3"; var top250Url = app.globalData.doubanBase + "/v2/movie/top250" + "?start0&count=3"; this.getMovieListData(inTheatersUrl,"inTheaters"); this.getMovieListData(comingSoonUrl,"comingSoon"); this.getMovieListData(top250Url,"top250") }, getMovieListData: function (url, settedKey){ var that = this; wx.request({ url: url, data: {}, method: "GET", header: { "Content-Type": "json" }, success(res) { that.processDoubanData(res.data, settedKey) } }) }, // 处理电影返回的数据 processDoubanData: function (moviesDouban, settedKey){ var movies = []; for(var idx in moviesDouban.subjects){ var subject = moviesDouban.subjects[idx]; var title = subject.title; if(title.length>=6){ title = title.substring(0,6)+"..." }; var temp = { //定义空对象 push到空数组 title: title, average:subject.rating.average,//评分 coverageUrl:subject.images.large,//海报图片 movieId:subject.id } movies.push(temp) } var readyData = {}; readyData[settedKey] = { movies:movies } this.setData(readyData) console.log(readyData) }, }) 00
- 
				  7七月 2018-12-28 版本不会有问题的,贴代码看下。没报错多半是 你在wxml里的解析有问题。 032019-01-01
相似问题
