SPA課程const疑問

原本是使用

export default new VueRouter({
    mode:'history',
    routes,
})

改成了

const router = new VueRouter({
    mode:'history',
    routes,
})

export default router

頁面就不會出來了
我在想是不是const的原因?
因為console也沒有任何的錯誤
想請教大神這要怎麼排除

JellyBool

这个应该没有什么关系的才对。

shihherokai 回复 JellyBool

抱歉 更正一下
是多了


router.beforeEach((to, from, next) => {
    if(to.meta.requiresAuth){
        if(Store.state.authenticated){
            return next()
        }else{
            return next({'name': 'login'})
        }
    }
})

components就沒辦法宣染出來了

JellyBool 回复 shihherokai

Store.state.authenticated 接下来的视频有讲到:

Store.state.AuthUser.authenticated
shihherokai

我好像找到問題
我console.log(Store.state.authenticated) 出來是 undefined