場景:頁面 A 跳轉(zhuǎn)到頁面B,頁面B中要使用到A 中的數(shù)據(jù),且數(shù)據(jù)類型是object,但是又不想將數(shù)據(jù)存在localStorage,此時就可以巧用getCurrentPages
//?先從頁面棧中拿數(shù)據(jù)
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
????}