-
通过EventChannel建立页面间事件通信通道
// 跳转
wx.navigateTo({
url: '/pages/confirmOrder/confirmOrder',
success: res => {
res.eventChannel.emit('getList', list) //触发事件
}
})
// 接收
const eventChannel = this.getOpenerEventChannel()
eventChannel.on('getList', data => {
var list = data
})
- 通过encodeURIComponent转译
// 跳转
wx.navigateTo({
url: '/pages/confirmOrder/confirmOrder?list=' + encodeURIComponent(JSON.stringify(list)),
})
// 接收
var list = JSON.parse(decodeURIComponent(options.list))
- 通过全局变量globalData
// app.js
globalData: {
list: []
}
// 赋值
getApp().globalData.list = list
// 取值
var list = getApp().globalData.list
- 通过缓存
// 存
wx.setStorageSync('list', list)
// 取
var list = wx.getStorageSync('list')