【发布时间】:2017-12-04 09:46:38
【问题描述】:
尝试使用导航守卫,但next('/auth/login') 给出了无限循环:
router.beforeEach((to, from, next) => {
auth.validate().then((valid) => {
if (!valid) {
next('/auth/login')
} else {
next()
}
})
})
路由器已定义:
const router = new Router({
routes: [
{
name: 'login',
path: '/auth/login',
component: login
}
})
【问题讨论】:
-
我在这里发布了 vue-router v4.x 的解决方案:stackoverflow.com/a/68009594/1219079
标签: vue.js vue-router