|
|
@@ -170,11 +170,14 @@ router.afterEach((to, from) => {
|
|
|
});
|
|
|
|
|
|
router.onError((error) => {
|
|
|
+ console.log('routerError:message', error.message)
|
|
|
+ console.log('routerError:targetPath', router.history.pending.fullPath)
|
|
|
NProgress.done();
|
|
|
- ElNotification.error({
|
|
|
- title: "路由错误",
|
|
|
- message: error.message
|
|
|
- });
|
|
|
+ const pattern = /Loading chunk (\d)+ failed/g;
|
|
|
+ const isChunkLoadFailed = error.message.match(pattern);
|
|
|
+ const targetPath = router.history.pending.fullPath;
|
|
|
+ if (isChunkLoadFailed) router.replace(targetPath);
|
|
|
+ else ElNotification.error({ title: "路由错误", message: error.message });
|
|
|
});
|
|
|
|
|
|
// 生成路由对象
|