多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
### 绑定电影类型标题 > 把类型传进来,并绑定 `movies.js` ~~~javascript processDoubanData: function (moviesDouban, settedKey, categoryTitle){ var movies = []; for(var ids in moviesDouban.subjects){ var subject = moviesDouban.subjects[ids]; var title = subject.title; if(title.length>6){ title = title.substring(0,6) + "..."; } var temp = { stars:util.convertToStarsArray(subject.rating.stars), title:title, average:subject.rating.average, coverageUrl:subject.images.large, movieId:subject.id } movies.push(temp); } var readyData = {}; readyData[settedKey] = { categoryTitle: categoryTitle, movies:movies }; this.setData(readyData); }, ~~~ ### 实现到详情页的跳转 `app.json` > 创建更多电影页面 ~~~json "pages/movies/more-movie/more-movie" ~~~ `movie-list-template.wxml` ~~~html <text class="slogan">{{categoryTitle}}</text> <view catchtap="onMoreTap" class="more" data-category="{{categoryTitle}}"> <text class="more-text">更多</text> <image class="more-img" src="/images/icon/arrow-right.png"></image> </view> ~~~ `movies.js` ~~~javascript onMoreTap:function(event){ var category = event.currentTarget.dataset.category; wx.navigateTo({ url: 'more-movie/more-movie?category='+category, }) }, ~~~ `more-movie.js` ~~~javascript onLoad: function (options) { var category = options.category; console.log(category); }, ~~~ ### 动态设置导航栏标题 `more-movie.js` ~~~javascript onLoad: function (options) { var category = options.category; this.setData({ navigateTitle:category }) console.log(category); }, onReady:function(event){ wx.setNavigationBarTitle({ title: this.data.navigateTitle }) }, ~~~