A頁面傳回index頁面重新整理資料onLoad和onShow頁面傳參解決
三種場景
一、index頁面不需要識别不同入口
二、有很多頁面“跳轉”到B頁面,是以onLoad需要接收url傳參,識别不同入口。
在隻有A頁面是“傳回”的情況,可以固定寫法onShow加載this.onLoad({route:'a'})
三、如果有多頁面“跳轉”或“傳回”index頁面的情況,在需要傳回的頁面設定同名本地存儲,index頁面onShow擷取本地存儲來識别不同入口
index.js
第一種場景
onLoad: function(){
},
onShow: function(){
this.onLoad();
}
第二種場景
onLoad: function(options){
console.log(options.route);
},
onShow: function(){
this.onLoad({route:'a'});
}
第三種場景
onLoad: function(options){
console.log(options.route);
},
onShow: function(){
this.onLoad({route: wx.getStorageSync('route')});
}