父向子组件传参
父组件传递
user(e) {
let id = e.currentTarget.dataset.id;
let detail = e.currentTarget.dataset.detail;
wx.navigateTo({
url: '/pages/member/package-payment-code/package-payment-code?id=' + id + '&detail=' + detail
})
},
子组件接受
onLoad: function(options) {
if (options.type == 1) {
wx.setNavigationBarTitle({
title: "套餐付款码"
})
this.setData({
boln: true
})
} else {
wx.setNavigationBarTitle({
title: "券付款码"
})
this.setData({
boln: false,
detail: options.detail
})
}
if (options.id) {
this.setData({
id: options.id
})
}
},
子向父组件及祖组件传参
let author = "true"
that.triggerEvent("traCheckedNum", author)
<dialogBar wx:if="{{meal.IsUse && meal.IsIncrease}}" meal="{{meal}}" type='0' bind:traCheckedNum="traCheckedNum" skinStyle="{{skinStyle}}">
traCheckedNum: function (e) {
console.log(e.detail)
this.triggerEvent('myevent', e)
},
<setMeal meal="{{item}}" skinStyle="{{skinStyle}}" bind:myevent='getMask' index="{{navIndex}}"/>
getMask(e) {
console.log(e.detail.detail);
if (e.detail.detail) {
this.onShow();
}
},