uniapp发现getCurrentPages可以用,试试效果
在登录页面,存起
let pages = getCurrentPages(); let prevPage = pages[pages.length - 2]; if(prevPage.route!='pages/product/product'){ uni.setStorage({ key:'beforeLoginPage', data:prevPage.$page.fullPath }); // console.log('prevPage',prevPage.route); }
登录后跳转
//页面跳转 uni.getStorage({ key:'beforeLoginPage', success: (res) => { console.log('beforeLoginPage',res.data); let switchTabList = ['/pages/use/use']; // switchTabList.some(res.data); // console.log('switchTabList.some(res.data)',switchTabList.includes(res.data)); if(switchTabList.includes(res.data)){ uni.switchTab({ url: res.data, success: () => { uni.removeStorage({ key:'beforeLoginPage' }) } }); }else{ uni.navigateTo({ url: res.data, success: () => { uni.removeStorage({ key:'beforeLoginPage' }) } }); } } });