小编Har*_*han的帖子

如何在 Nuxt.js 中设置 beforeResolve 导航守卫

有没有办法在 nuxt.config.js 中添加 beforeResolve 导航守卫?

我的 nuxt.config.js

module.exports {
    ...
    router: {
        beforeResolve(to, from, next) {
            if (this.$store.getters.isLoggedIn)
                 next('/resource')
        }
    }
    ...
}
Run Code Online (Sandbox Code Playgroud)

但它永远不会被调用!

我一直在尝试根据 vuex 商店上的用户登录状态在安装组件之前实现重定向。

vue.js vue-router vuex nuxt.js

6
推荐指数
1
解决办法
4879
查看次数

标签 统计

nuxt.js ×1

vue-router ×1

vue.js ×1

vuex ×1