Refused to apply style from 'http://localhost:8080/XXX.css' because its MIME type ('text/html') i...

发现问题:

今天用express+node搭建静态前台登录页面时,遇见了一个坑


报错说:

Refused to apply style from 'http://localhost:8081/dist/css/swiper.min.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

其实就是加载不出css模块

解决办法:

在app.js中添加一段代码:

app.use(express.static(__dirname)); //加上了这个就可以访问了,static参数为静态文件存放目录:__dirname代表目录

最后成功打开页面:

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容