资源解释为脚本,但使用MIME类型text / x-c ++传输 [英] Resource interpreted as Script but transferred with MIME type text/x-c++
问题描述
没有初学者。
在下面写了一个测试html
Wrote a test html below
<head>
<link rel="stylesheet" type="text/css" href="404.less">
<script src="http://lesscss.googlecode.com/files/less-1.3.0.min.js" type="text/javascript"></script>
</head>
<body>test</body>
但在Chrome中收到警告
But got a warning in Chrome
资源解释为脚本,但以MIME类型text / x-c ++:http://lesscss.googlecode.com/files/less-1.3.0.min.js传输。
Resource interpreted as Script but transferred with MIME type text/x-c++: "http://lesscss.googlecode.com/files/less-1.3.0.min.js".
为什么?
推荐答案
您可能希望您的链接标记说:
You probably want your link tag to say:
<link rel="stylesheet/less" type="text/css" href="404.less">
也就是说,如果这是从一个web服务器提供服务,可能是检测mime类型错误从文件扩展名。如果它是一个apache服务器,虽然,有一个简单的修复。添加到/在您的webroot中创建一个.htaccess文件,包含以下行:
That said, if this is being served from a webserver it could be that that's detecting the mime type wrong from the file extension. If it's an apache server though, there's an easy fix. Add this to/create a .htaccess file in your webroot, containing the line:
AddType text/css less
这篇关于资源解释为脚本,但使用MIME类型text / x-c ++传输的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!