perf: 页面切换性能优化 (#600)

* perf: 页面切换性能优化

* fix: 修复刷新页面时`router.beforeEach`调用两次的问题
This commit is contained in:
xiaoming
2023-06-13 12:36:54 +08:00
committed by GitHub
parent aec2a35424
commit 5d86b714a4
9 changed files with 28 additions and 83 deletions

View File

@@ -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();