小程序处理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
});
}
posted @ 2020-03-17 17:58  yh不可说  阅读(752)  评论(0编辑  收藏  举报