Skip to content

Commit

Permalink
修复路由跳转不成功的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
lsgwr committed Nov 26, 2019
1 parent efcbd1f commit b5a13a1
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions code/frontend/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const routes = [
}
]

let router = new VueRouter({
const router = new VueRouter({
routes
})

Expand Down Expand Up @@ -93,9 +93,7 @@ function addDynamicMenuAndRoutes (userName, to, from) {
// Todo:下面这两行很精巧,重点理解下
router.options.routes[0].children = router.options.routes[0].children.concat(dynamicRoutes)
// 重新设置router,要不每次都addRoutes会导致路由重复添加
router = new VueRouter({
routes
})
router.addRoutes(router.options.routes)
store.commit('menuRouteLoaded', true)
store.commit('setNavTree', res.data)
})
Expand Down

0 comments on commit b5a13a1

Please sign in to comment.