beforeEach中的next()函数不能正常使用router.beforeEach vue js

时间:2019-05-27 09:35:52

标签: laravel vue.js vue-router

我使用了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);
        .....

0 个答案:

没有答案