vueAdmin使用动态路由时踩坑

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

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

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

if (to.redirectedFrom !== undefined) {
  next({
    path: to.redirectedFrom
  })
} else {
  next({ ...to
  })
}
posted @ 2018-10-01 11:45  NewObject_1  阅读(382)  评论(0编辑  收藏  举报