我使用了router.beforeEach
,但是对next()
函数的调用不起作用。下一个变量返回错误。这是功能:
router.beforeEach((to, from, next) => {
if (to.matched.some(record => record.meta.requiresAuth)) {
// this route requires auth, check if logged in
// if not, redirect to login page.
if (!auth.loggedIn()) {
next({
path: '/login',
query: { redirect: to.fullPath }
})
} else {
next()
}
} else {
console.log(next);
next() // make sure to always call next()!
}
})
这是错误,在日志中显示为下一个变量的值...
ƒ (to) {
if (to === false || isError(to)) {
// next(false) -> abort navigation, ensure current URL
this$1.ensureURL(true);
abort(to);
.....