1. 列表给值
<view class='item' wx:for="{{lesson}}" wx:key="ID" wx:for-item="item">
2. 点击事件 并传值
<label id="btnCollect_40" class='deletecolor' bindtap="collectionClick" data-id='{{item.ID}}' wx:else>收藏</label>
取值
collectionClick:function(event){
var id = event.currentTarget.dataset.id;
}
3.跳转页面带值
ShowResourceList:function(event){
var id = event.currentTarget.dataset.id;
wx.navigateTo({
url: '../detail/detail?id='+id
})
},
取值
onLoad: function (options) {
//获取参数
var typeid = options.id;
},
2)传递多个参数
wx.navigateTo({
url: '../tingxie/tingxie?id=' + that.data.audioID + "&url=" + that.data.audiourl + "&classlist=" + sa + "&random=" +random_s1 + "&readnumber=" + that.data.readnumber
})
取值
onLoad: function (options) {
var typeid = options.id;
var url = options.url;
var classlist = JSON.parse(options.classlist);
var random_s1 = options.random;
......
}
分享
onLoad: function () {
//转发
wx.showShareMenu({
withShareTicket: true
})
},
2)无参数分享
onShareAppMessage: function () {
let users = wx.getStorageSync('user');
return {
title: '语文家听',
path: 'pages/index/index',
success: function (res) { }
}
},
3)带参数分享
//转发带参数
onShareAppMessage: function (res) {
let users = wx.getStorageSync('user');
if (res.from === 'button') { }
return {
title: this.data.ResourceName,
path: 'pages/detail/detail?id=' + this.data.id + "&type=" + this.data.typebar,
success: function (res) { }
}
},