Skip to content

Commit e852ec1

Browse files
rysinalsendya
authored andcommitted
修复动态路由重复添加可能导致的页面卡死BUG
1 parent 9e2606f commit e852ec1

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/router/index.js

+15-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,18 @@ Router.prototype.push = function push (location, onResolve, onReject) {
1111

1212
Vue.use(Router)
1313

14-
export default new Router({
15-
mode: 'history',
16-
routes: constantRouterMap
17-
})
14+
const createRouter = () =>
15+
new Router({
16+
mode: 'history',
17+
routes: constantRouterMap
18+
})
19+
20+
const router = createRouter()
21+
22+
// 定义一个resetRouter 方法,在退出登录后或token过期后 需要重新登录时,调用即可
23+
export function resetRouter () {
24+
const newRouter = createRouter()
25+
router.matcher = newRouter.matcher
26+
}
27+
28+
export default router

0 commit comments

Comments
 (0)