错误信息

使用 Vite 打包的网页白屏,控制台报错。

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of “text/plain”. Strict MIME type checking is enforced for module scripts per HTML spec.

原因

MIME 的类型错误,一般是本地 windows 下开发会遇到的问题。我就是在Windows 下用 Python 内置的 http.server 打开后遇到的。

解决方案

将打包后的文件部署在正式的服务器环境下(如 Nginx、Apache)。
请添加图片描述

参考资料

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐