场景:页面 A 跳转到页面B,页面B中要使用到A 中的数据,且数据类型是object,但是又不想将数据存在localStorage,此时就可以巧用getCurrentPages
// 先从页面栈中拿数据
const pages = getCurrentPages()
const myPage = pages.find(item => {
return item.route === '/pages/order-detail/order-detail'
})
if (myPage) {
this.setData({
data: myPage.data.order,
loading: false
})
return
}