mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-03 13:44:47 +08:00
perf: 页面切换性能优化 (#600)
* perf: 页面切换性能优化 * fix: 修复刷新页面时`router.beforeEach`调用两次的问题
This commit is contained in:
@@ -176,7 +176,8 @@ router.beforeEach((to: toRouteType, _from, next) => {
|
||||
}
|
||||
}
|
||||
}
|
||||
router.push(to.fullPath);
|
||||
// 确保动态路由完全加入路由列表并且不影响静态路由(注意:动态路由刷新时router.beforeEach可能会触发两次,第一次触发动态路由还未完全添加,第二次动态路由才完全添加到路由列表,如果需要在router.beforeEach做一些判断可以在to.name存在的条件下去判断,这样就只会触发一次)
|
||||
if (isAllEmpty(to.name)) router.push(to.fullPath);
|
||||
});
|
||||
}
|
||||
toCorrectRoute();
|
||||
|
||||
Reference in New Issue
Block a user