通过navigateTo,reLaunch在跳转地址后面加后缀
// 点击跳转
indexTargetLogs1: function () {
wx.reLaunch({
url: '../logs/logs?logsView=1',
})
},
indexTargetLogs2: function (e) {
wx.reLaunch({
url: '../logs/logs?logsView=2',
})
},
indexTargetLogs3: function () {
wx.reLaunch({
url: '../logs/logs?logsView=3',
})
},
对应跳转的页面用options接收参数
onLoad: function (options) {
this.setData({
logsView: options.logsView
})
}
通过全局变量传递参数。
app.js
globalData: {
js_code:null
}
page1
wx.login({
success: function (res) {
if (res.code) {
app.globalData.js_code = res.code
}
}
})
page2
console.log(app.globalData.js_code)
感谢友军的帮助
小程序在全局有global对象,通过在global对象挂载属性,可在页面之前相互调用。