小程序官網(wǎng)關(guān)于Navigator介紹:

image.png
open-type = navigate
對應(yīng) wx.navigateTo的功能
open-type = redirect
對應(yīng) wx.redirectTo的功能
open-type = switchTab
對應(yīng) wx.switchTab的功能
open-type = reLaunch
對應(yīng) wx.reLaunch的功能
[1.1.0](https://mp.weixin.qq.com/debug/wxadoc/dev/framework/compatibility.html)
navigateBack
對應(yīng) wx.navigateBack的功能
頁面跳轉(zhuǎn)時傳遞
主頁面:
<!-- sample.wxml -->
<view class="btn-area">
<navigator url="/page/navigate/navigate?title=newPagePath" hover-class="navigator-hover">跳轉(zhuǎn)到新頁面</navigator>
<navigator url="../../redirect/redirect/redirect?title=重定向頁面&ohterParmas=123" open-type="redirect" hover-class="other-navigator-hover">在當(dāng)前頁打開</navigator>
<navigator url="/page/index/index" open-type="switchTab" hover-class="other-navigator-hover">切換 Tab</navigator>
</view>
這里是帶參跳轉(zhuǎn)的,一個參數(shù)就用?=title,如果多個參數(shù)就是用?=title=”“&ohterParmas=”“。
頁面跳轉(zhuǎn)后,onload接受參數(shù)
Page({
data:{
//不需要再寫user_id。
},
onLoad(options) {
console.log('onLoad')
console.log(options.user_id)
if (options.user_id) {
this.setData({
user_id: options.user_id
})
} else {
this.setData({
user_id: '暫無'
})
}
}