uniapp:监听页面跳转到tabbar,进行拦截

uni.addInterceptor:可拦截接口请求‘request’,或者tabbar页面跳转‘switchTab’。

onLaunch: function() {
    
    
	// 监听tabbar页面跳转,如果url == ''  就提示暂未开放。
	uni.addInterceptor('switchTab', {
    
    
		invoke(e) {
    
    
			console.log(e)
			if(e.url == '/pages/mine/mine'){
    
    
				uni.showToast({
    
    
					icon:'none',
					mask:true,
					title: '暂未开放',
				});
				return false;
			}
		},
		success: (e) => {
    
    
			console.log('OK',e)
		}
	})
}	

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_40745143/article/details/129581181