使用uni-simple-router app端启动页为tab时
2021-08-29 本文已影响0人
flyjar
使用uni-simple-router app端启动页为tab时,拦截到其他页面,tabbar依然存。此问题与uni-simple-router开发者沟通过,暂时无法解决。可以避免将首页设置为tab页面,可以将登录页面设置为首页。在beforeEach或者routerBeforeEach中进行处理。请参考以下代码
// router.js
import {
RouterMount,
createRouter
} from '../uni_modules/hhyang-uni-simple-router/uni-simple-router';
import store from '@/store';
const router = createRouter({
platform: process.env.VUE_APP_PLATFORM,
App: {
registerLoadingPage: true,
launchedHook: () => {
console.log('test')
}
},
routes: [...ROUTES],
// 请参考此处
routerBeforeEach: (to, from, next) => {
let loginPath = '/pages/login/sign-in/sign-in'
if (store.state.vuex_token) {
if (to.path === loginPath) {
next({
path: '/pages/tabs/index/index',
NAVTYPE: 'pushTab',
})
} else {
next()
}
} else {
if (to.path === loginPath) {
next()
} else {
next({
path: loginPath,
NAVTYPE: 'push'
})
}
}
},
});
export {
router,
RouterMount
}