美文网首页
使用uni-simple-router app端启动页为tab时

使用uni-simple-router app端启动页为tab时

作者: flyjar | 来源:发表于2021-08-29 09:22 被阅读0次

使用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
}

相关文章

网友评论

      本文标题:使用uni-simple-router app端启动页为tab时

      本文链接:https://www.haomeiwen.com/subject/oajwiltx.html