Failed to load module script: The server responded with a non-JavaScript MIME type of “text/html”.
2022/5/1 9:13:11
本文主要是介绍Failed to load module script: The server responded with a non-JavaScript MIME type of “text/html”.,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
vue3+vite打包以后,项目切换路由触发(偶发触发)报:
After using vue-router, there is an error in packaging and running # Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
Failed to fetch dynamically imported module.....
确实应该是vite2.xx的bug https://github.com/vitejs/vite/issues/863
注意: 在使用vue3+vite时候,只发现vue-router切换时触发此现象
问题:
// vue3+vite此种异步路由引入方法 开发调试时确实没有问题,但是vite打包以后就会触发报错 routes: [ { path: "/", name: "Home", component: import(`../views/${view}.vue`) } ]
解决方法:
// 这样引用虽然解决了问题(浏览器会提醒,不用管),但是在一些win10自带的低版本edge浏览器中还是会稀有触发 // 应该确实是vite的兼容性bug问题 import { defineAsyncComponent } from 'vue'; //异步组挂载器 routes: [ { path: "/", name: "Home", component: defineAsyncComponent(() => import('../views/Home.vue')); }, { path: "/about", name: "About", component: defineAsyncComponent(() => import('../views/About.vue')); } ]
后续持续跟进中...
这篇关于Failed to load module script: The server responded with a non-JavaScript MIME type of “text/html”.的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-06-05做软件测试需要懂代码吗?
- 2024-06-0514-ShardingSphere的分布式主键实现
- 2024-06-03为什么以及如何要进行架构设计权衡?
- 2024-05-31全网首发第二弹!软考2024年5月《软件设计师》真题+解析+答案!(11-20题)
- 2024-05-31全网首发!软考2024年5月《软件设计师》真题+解析+答案!(21-30题)
- 2024-05-30【Java】百万数据excel导出功能如何实现
- 2024-05-30我们小公司,哪像华为一样,用得上IPD(集成产品开发)?
- 2024-05-30java excel上传--poi
- 2024-05-30安装笔记本应用商店的pycharm,再安排pandas等模块,说是没有打包工具?
- 2024-05-29java11新特性