vuejs / router

🚦 The official router for Vue.js
https://router.vuejs.org/
MIT License
3.91k stars 1.19k forks source link

断网状态下push到懒加载的路由,提示js加载失败, 联网后此路由仍无法加载 #2059

Closed renqiankun closed 10 months ago

renqiankun commented 10 months ago

Reproduction

断网状态下懒加载路由

Steps to reproduce the bug

1.断网后第一次router.push 一个懒加载的路由 2.浏览器提示js加载失败,页面无反应 3.联网后跳转同一个路由,浏览器仍然提示js加载失败、页面无反应

Expected behavior

可以重新加载js或可以捕获到懒加载路由的js加载错误

Actual behavior

TypeError: Failed to fetch dynamically imported module: http://192.168.200.1:5174/src/views/ancillary-services/declare-plan/index.vue triggerError @ vue-router.mjs:3451 (anonymous) @ vue-router.mjs:3173 Promise.catch (async) pushWithRedirect @ vue-router.mjs:3167 push @ vue-router.mjs:3099 handleMenu @ sidebar-item.vue:42 (anonymous) @ sidebar-item.vue:4 (anonymous) @ runtime-dom.esm-bundler.js:1483 callWithErrorHandling @ runtime-core.esm-bundler.js:173 callWithAsyncErrorHandling @ runtime-core.esm-bundler.js:182 invoker @ runtime-dom.esm-bundler.js:345 :5174/#/join-manage/…ad-analysis/index:1 Uncaught (in promise) TypeError: Failed to fetch dynamically imported module: http://192.168.200.1:5174/src/views/ancillary-services/declare-plan/index.vue

Additional information

No response

renqiankun commented 10 months ago

使用route.components.default().catch可以捕获