小程序处理navigateTo多次跳往相同页面返回获取之前数据

//在onShow里执行
const pages = getCurrentPages();//获取所有页面栈
const currPage = pages[pages.length - 1]; // 当前页
//判断是否当前页面有存储数据,有的话使用,没有存储
if(currPage.data.Id !== undefined){
this.id = currPage.data.Id || this.id;
}else {
currPage.setData({
Id: this.id
});
}
原文地址:https://www.cnblogs.com/ycyh1314/p/12512357.html