Not much to say, go directly to the code, there are comments in the code
// 点击地址选中地址返回上一个页面
seleect_site(e){
console.log(e)
let item=encodeURIComponent(JSON.stringify(e.currentTarget.dataset.item))
var pages = getCurrentPages();
var prevPage = pages[pages.length - 2]; //上一个页面
// 调用上一个页面对象的setData()方法,把数据存到上一个页面中去
prevPage.setData({
item:item
});
// 返回上一个页面
wx.navigateBack({
delta: -1
});
},
Then in the code of the previous page
onShow: function (options) {
console.log(JSON.parse(decodeURIComponent(this.data.item)))
let item=JSON.parse(decodeURIComponent(this.data.item))
wx.setStorageSync('site',JSON.parse(decodeURIComponent(this.data.item)) )
this.setData({
item:item
})
},
It needs to be in onShow, because it needs to be updated in real time, so it needs to monitor the page display