带参跳转
wx.navigateTo({
url: '/pages/hope/hope?isHope=' + 0,
})
跳转的页面有一个参数初始化isHope : 1
Page传值Component
Component中定义show
属性
properties: {
show: {
type: "Boolean",
value: Boolean,
observer: function (news, olds, path) {
}
}
}
Page中wxml中该Component(joinHope-cmp
)绑定
<joinHope-cmp show="{{showJoinHope}}">
</joinHope-cmp>
通过改变Page中showJoinHope
的值传递给Component的show
this.setData({
showJoinHope: true,
})
Component传值Page
Component中已wishSuccess
名字,e
是传递的参数
var e = {
success: true
}
this.triggerEvent('wishSuccess', e, '');
Page的wxml给组件绑定bind:wishSuccess="onWishSuccess"
<hopeLike-cmp class='hopeLike_container' carData="{{carData}}" bind:wishSuccess="onWishSuccess">
</hopeLike-cmp>
并实现onWishSuccess
方法,从event
取参
onWishSuccess: function (event){
}
网友评论