景徳镇旅游微信小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

29 lines
670 B

let needLogin = [
// "/pages/user/user",
]
let list = ["navigateTo"];
list.forEach(item => { //用遍历的方式分别为,uni.navigateTo,uni.redirectTo,uni.reLaunch,uni.switchTab这4个路由方法添加拦截器
console.log(item, 'router list item')
uni.addInterceptor(item, {
invoke(e) { // 调用前拦截
let length = getCurrentPages().length
if (length >= 10) {
uni.showToast({
title: '页面栈已满,即将回到首页',
icon: 'none'
})
setTimeout(uni.reLaunch, 1000, {
url: '/pages/index/index'
})
return false
}
return true
},
fail(err) { // 失败回调拦截
console.log(err);
},
})
})