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代表目录

最后成功打开页面:

你可能感兴趣的:(Refused to apply style from 'http://localhost:8080/XXX.css' because its MIME type ('text/html') i...)