wx.navigateTo(Object object)
保留当前页面,跳转到应用内的某个页面。但是不能跳到 tabbar 页面。使用 wx.navigateBack 可以返回到原页面。跳转的url可以加上需要传递的参数。
toPage(){
wx.navigateTo({
url: '/pages/user/user?name=hello',
})
},
接收参数:在接收页面的onLoad方法中
onLoad(options) {
this.setData({
text: options.name
});
},
wx.switchTab(Object object)
当跳转到的页面是tabbar页面时,需要使用wx.switchTab,而跳转的url里面不允许带参数。那么当需要传递参数时,可以使用全局变量。
列如 getApp().globalData.custom传递参数,接收的页面使用 getApp().globalData. custom来接收。
toTab(){
getApp().globalData.pic="world"
wx.switchTab({
url: '/pages/pic/pic',
})
},
接收参数:
onLoad(options) {
this.setData({
pic: getApp().globalData.pic
})
},
© 版权声明
文章版权归作者所有,未经允许请勿转载。如内容涉嫌侵权,请在本页底部进入<联系我们>进行举报投诉!
THE END















暂无评论内容