ChunkLoadError: Loading chunk {n} failed.
原文链接:https://blog.csdn.net/m0_37805167/article/details/130963928。偶现路由切换,控制台报错 ChunkLoadError: Loading chunk {n} failed.可能是远程资源更新,浏览器缓存,出现静态资源不一致等原因造成的。
·
问题描述
偶现路由切换,控制台报错 ChunkLoadError: Loading chunk {n} failed.
问题分析
可能是远程资源更新,浏览器缓存,出现静态资源不一致等原因造成的
简易版解决办法
router.onError((error) => {
const pattern = /Loading chunk (\d)+ failed/g;
const isChunkLoadFailed = error.message.match(pattern);
const targetPath = router.history.pending.fullPath;
if (isChunkLoadFailed) {
router.replace(targetPath);
}
})
原文链接:https://blog.csdn.net/m0_37805167/article/details/130963928
更多推荐




所有评论(0)