在路由守护方法router.beforeEach中如果有使用动态路由,注意此时的路由对当前的router无效,下次路由时才起效。

导致的问题是---- 当页面刷新或重新打开页面时,无法找到当前路由(跳转404)

为了解决此问题,将跳转next()改为

if (to.redirectedFrom !== undefined) {
  next({
    path: to.redirectedFrom
  })
} else {
  next({ ...to
  })
}

相关文章:

  • 2021-04-27
  • 2023-01-21
  • 2022-12-23
  • 2021-09-01
  • 2021-10-08
  • 2022-12-23
  • 2021-11-26
  • 2021-05-26
猜你喜欢
  • 2021-12-31
  • 2021-05-24
  • 2021-09-14
  • 2022-12-23
  • 2021-08-24
  • 2021-06-14
  • 2021-05-13
相关资源
相似解决方案