0

我正在使用 nuxtjs、vuex 和 vuex-persist 插件。我已将中间件添加到所有页面。它工作正常,但每当我刷新页面时,auth.js 中间件会不断重定向到登录页面,即使用户已通过身份验证(真)。

Auth.js 中间件

export default function({store, redirect}){
    if (store.state.isLogin == false) {
        return redirect('/login')
    }
}

Store.js

export const state = () => ({
    isLogin: false,
})

export const mutations = {
    setLogin(state) {
        state.isLogin = true
    },
    removeLogin(state){
        state.isLogin = false
    }
}
4

0 回答 0