defineAsyncComponent 动态导入组件,到包后找不到资源,vite 3+vue3
Vue version
3.2.37
Link to minimal reproduction
没
Steps to reproduce
const modules: any = import.meta.glob('./*.vue'); const readTraining = defineAsyncComponent(modules['./readTraining.vue']); 本地加载正常,打包之后不正常 http://localhost:8888/js/Index/Index.42f9fc46.js 404 (Not Found) vue-router.0434762d.js:6 TypeError: Failed to fetch dynamically imported module: http://localhost:8888/js/Index/Index.42f9fc46.js
What is expected?
预期是动态加载正常,资源不丢失,使用的时候家长
What is actually happening?
目前打包后找不到资源了
System Info
index-46178cb2.js:1 GET http://localhost:8888/js/Index/Index.42f9fc46.js 404 (Not Found)
(匿名) @ index-46178cb2.js:1
he @ index-46178cb2.js:1
component @ index-46178cb2.js:1
Ye @ vue-router.0434762d.js:6
(匿名) @ vue-router.0434762d.js:6
Promise.then(异步)
M @ vue-router.0434762d.js:6
T @ vue-router.0434762d.js:6
R @ vue-router.0434762d.js:6
install @ vue-router.0434762d.js:6
use @ @vue.d4d18b9b.js:1
(匿名) @ index-46178cb2.js:3
vue-router.0434762d.js:6 [Vue Router warn]: uncaught error during route navigation:
P @ vue-router.0434762d.js:6
Y @ vue-router.0434762d.js:6
(匿名) @ vue-router.0434762d.js:6
Promise.catch(异步)
T @ vue-router.0434762d.js:6
R @ vue-router.0434762d.js:6
install @ vue-router.0434762d.js:6
use @ @vue.d4d18b9b.js:1
(匿名) @ index-46178cb2.js:3
vue-router.0434762d.js:6 TypeError: Failed to fetch dynamically imported module: http://localhost:8888/js/Index/Index.42f9fc46.js
Y @ vue-router.0434762d.js:6
(匿名) @ vue-router.0434762d.js:6
Promise.catch(异步)
T @ vue-router.0434762d.js:6
R @ vue-router.0434762d.js:6
install @ vue-router.0434762d.js:6
use @ @vue.d4d18b9b.js:1
(匿名) @ index-46178cb2.js:3
vue-router.0434762d.js:6 [Vue Router warn]: Unexpected error when starting the router: TypeError: Failed to fetch dynamically imported module: http://localhost:8888/js/Index/Index.42f9fc46.js
Any additional comments?
什么时候修复这个
I think build related issues, I think more likely a problem with vite, you can open an issue in vite