请问我用浏览器访问html文件报错如下的原因是什么:Refused to apply style from 'http://localhost:8081/wangye/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
时间: 2023-03-27 19:03:33 浏览: 112
这个错误是因为浏览器检测到 style.css 文件的 MIME 类型为 text/html,而不是支持的样式表 MIME 类型,因此拒绝应用样式。严格的 MIME 检查是启用的。您可以检查 style.css 文件的 MIME 类型是否正确,并确保服务器正确配置了 MIME 类型。
相关问题
Refused to apply style from ‘http://localhost:8080/src/assets//css/reset.css‘
这个问题是由于文件的MIME类型不是受支持的样式表MIME类型,导致样式无法应用。解决方法是将CSS文件移动到public目录下的CSS文件夹中。
以下是解决方法的示例代码:
```html
<!-- 将CSS文件移动到public目录下的CSS文件夹中 -->
<link rel="stylesheet" href="/css/reset.css">
```
请注意,上述代码中的"/css/reset.css"是相对于public目录的路径,确保路径正确。
为什么我的html文件已经写了如下代码:<link rel="stylesheet" type = "text/css" href="style.css">但浏览器打开它的时候仍然报错:Refused to apply style from 'http://localhost:8081/wangye/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
可能是因为你的 style.css 文件的 MIME 类型不正确,应该是 text/css,而不是 text/html。你可以在服务器端配置正确的 MIME 类型,或者在 HTML 文件中使用内联样式。