拒绝应用来自 '' 的样式,因为其 MIME 类型 ('text/html') 不是受支持的样式表 MIME 类型,并且启用了严格的 MIME 检查 [英] Refused to apply style from '' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled

查看:447
本文介绍了拒绝应用来自 '' 的样式,因为其 MIME 类型 ('text/html') 不是受支持的样式表 MIME 类型,并且启用了严格的 MIME 检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Vue.js 项目,当我检查控制台时发现这个问题如下:

<块引用>

拒绝应用来自 '

我搜索了SO,找到了一个Angular 相关帖子,但这对我没有帮助,它们基于不同的前端框架.

解决方案

此错误消息的常见原因是当浏览器尝试加载该资源时,服务器会返回一个 HTML 页面,例如,如果您的路由器捕获到未知路径并显示一个没有 404 错误的默认页面.当然,这意味着路径不会返回预期的 CSS 文件/图像/图标/任何东西.

为确保您在这种情况下,复制路径并尝试在新的浏览器窗口或选项卡中直接访问它.您将看到您的服务器发送的内容.

解决方案是找到正确的路径和路由器配置,以便在访问该路径时获得纯 CSS 文件/图像等.

确切的路径和路由器配置取决于您设置项目的方式和您使用的框架.

I have a Vue.js project, when I check the console found this issue bellow:

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


I searchedSO, found a Angular related post, but it do not helps me, they are based on different frontend framework.

解决方案

The usual reason for this error message is that when the browser tries to load that resource, the server returns an HTML page instead, for example if your router catches unknown paths and displays a default page without a 404 error. Of course that means the path does not return the expected CSS file / image / icon / whatever.

To make sure you are in that case, copy the path and try to access it directly in a new browser window or tab. You will see what your server sends.

The solution is to find the correct path and router configuration so that you get your plain CSS file / image / etc. when accessing that path.

The exact path and router configuration depends on how you have setup your project and the framework you are using.

这篇关于拒绝应用来自 '' 的样式,因为其 MIME 类型 ('text/html') 不是受支持的样式表 MIME 类型,并且启用了严格的 MIME 检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆