<!-- 声明式导航 -->
<navigator url="/pages/home/home" open-type="switchTab">导航到tab相关页</navigator> <navigator url="/pages/other/other?name=zs&age=18" open-type="navigate">导航到普通页面</navigator> <navigator open-type="navigateBack" delta="1">后退导航</navigator>
<!-- 编程式导航 -->
<button bindtap="gotoMy">导航到tab相页</button> // 通过编程式导航到tab页面 gotoMy(){ wx.switchTab({ url: '/pages/contact/contact', }) },
<button bindtap="gotoOther">导航到普通页面</button> // 通过编程式导航到其他页 gotoOther(){ wx.navigateTo({ url: '/pages/other/other?name=zs&age=18', }) },
<button bindtap="gotoOther">后退</button> // 通过编程式导航后退 gotoOther(){ wx.navigateBack() },
<!-- 如何接收参数 -->
onLoad: function (options) {
console.log(options)
this.setData({
query:options //data中声明一个query
})
},
一、声明式导航
二、编程式导航
三、导航传参