问题描述:使用uni-starter组件后,在pages.json中配置了uniIdRouter,发下tabBar之间跳转失效
原因:查看文档发现有一句话【uniIdRouter底层使用navigateTo、redirectTo、reLaunch、switchTab的拦截器进行页面跳转拦截,不会拦截进入首页和点击原生tabbar。】
解决:取store.hasLogin中的登录状态,判断是否登录,没有登录就跳转到登录页面
<template>
<view class="page">
</view>
</template>
<script>
import {store} from '@/uni_modules/uni-id-pages/common/store.js'
export default {
data() {
return {
}
},
onShow() {
if(!store.hasLogin){
uni.redirectTo({
url: '/uni_modules/uni-id-pages/pages/login/login-withoutpwd',
});
}
},
methods: {
}
}
</script>