当我们动态添加路由之后 需要手动添加404重定向的路由 否则页面会一直404
如下

// get user info
const { pagesIndex } = await store.dispatch('user/getUserInfo');
// 匹配路由
const accessRoutes = await store.dispatch('permission/generateRoutes', pagesIndex)
// 添加动态路由 
router.addRoutes(accessRoutes.concat([{
  path: "*",
  redirect: "/404"
}]))
// hack method to ensure that addRoutes is complete
// set the replace: true, so the navigation will not leave a history record
next({ ...to, replace: true })
Logo

前往低代码交流专区

更多推荐