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

内容分享3周前发布
0 0 0

发现问题:

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

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

报错说:

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模块

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

解决办法:

在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...

最后成功打开页面:

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

© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
none
暂无评论...