多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
### 跳转传参 `post.js` ~~~javascript onPostTap:function(event){ var postId = event.currentTarget.dataset.postid; console.log(postId); wx.navigateTo({ url: 'post-detail/post-detail?id='+postId, }) }, ~~~ `post-detail.js` ~~~javascript onLoad: function (options) { var postId = options.id; // var postData = postsData.postList[postId]; //console.log(postData); //this.setData(postData); }, ~~~ ### 修改数据源 `posts-data.js` 数据源增加几个字段 ~~~json { date: "Sep 18 2016", title: "正是虾肥蟹壮时", imgSrc: "/images/post/crab.png", avatar: "/images/avatar/1.png", content: "菊黄蟹正肥,品尝秋之味。徐志摩把,“看初花的荻芦”和“到楼外楼吃蟹”,并列为秋天来杭州不能错过的风雅之事;用林妹妹的话讲是“螯封嫩玉双双满,", reading: "112", collection: "96", headImgSrc: "/images/post/crab.png", author: "林白衣", dateTime: "24小时前", detail: "菊黄蟹正肥,品尝秋之味。徐志摩把“看初花的荻芦”和“到楼外楼吃蟹”并列为秋天来杭州不能错过的风雅之事;用林妹妹的话讲是“螯封嫩玉双双满,壳凸红脂块块香”;在《世说新语》里,晋毕卓更是感叹“右手持酒杯,左手持蟹螯,拍浮酒船中,便足了一生矣。”漫漫人生长路,美食与爱岂可辜负?于是作为一个吃货,突然也很想回味一下属于我的味蕾记忆。记忆中的秋蟹,是家人的味道,弥漫着浓浓的亲情。\n\n是谁来自山川湖海,却囿于昼夜,厨房与爱? 是母亲,深思熟虑,聪明耐心。吃蟹前,总会拿出几件工具,煞有介事而乐此不疲。告诉我们螃蟹至寒,需要佐以姜茶以祛寒,在配备的米醋小碟里,亦添入姜丝与紫苏,前者驱寒后者增香。泡好菊花茶,岁月静好,我们静等。", postId: 0 } ~~~ `post-detail.js` ~~~javascript var postsData = require('../../../data/posts-data.js'); onLoad: function (options) { var postId = options.id; var postData = postsData.postList[postId]; console.log(postData); this.setData(postData); }, ~~~ `post-detail.wxml` ~~~html <view class="container"> <image class="head-image" src="{{headImgSrc}}"></image> <image class="audio" src="/images/music/music-start.png"></image> <view class="author-date"> <image class="avatar" src="{{avatar}}"></image> <text class="author">{{author}}</text> <text class="const-text">发表于</text> <text class="date">{{dateTime}}</text> </view> <text class="title">{{title}}</text> <view class="tool"> <view class="circle-img"> <image src='/images/icon/collection.png'></image> <image class="share-img" src='/images/icon/share.png'></image> </view> <view class="horizon"></view> </view> <text class="detail">{{detail}}</text> </view> ~~~