首页 前端知识 Refused to execute script from ‘‘ because its MIME type (‘text/html‘) is not executable, and strict

Refused to execute script from ‘‘ because its MIME type (‘text/html‘) is not executable, and strict

2024-02-03 12:02:50 前端知识 前端哥 58 282 我要收藏

报错如下:

 

Refused to execute script from 'http://localhost:8080/style.js?v=1.1' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

造成这个报错的情况有很多,比如服务器配置错误、缓存问题、代码错误、应用部署问题等等

这篇文章是在前端项目运行时产生的问题,

原因就是我在vue.config.js中设置了静态资源公共路径:

所以,重点来了,在public下的所有图片、js等等都属于静态资源,所以使用的时候同样要加上图第四行配置/admin/,如我的public目录下有个style.js文件:

那么,在index.html里引用的时候同样需要加上/admin/,如:

 

这样能够正常访问到style.js,尽管看起来不在/admin/目录下,但是因为上边第一张图我们已经配置过了,所以一定要加上./admin/

否则就会报错:

 

转载请注明出处或者链接地址:https://www.qianduange.cn//article/1185.html
标签
开发语言
评论
发布的文章

jQuery ---- 插件

2024-02-15 14:02:06

CSS-JavaScript-Jquery-Servlet

2024-02-15 14:02:00

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!