资源解释为脚本,但使用MIME类型text / x-c ++传输 [英] Resource interpreted as Script but transferred with MIME type text/x-c++

查看:938
本文介绍了资源解释为脚本,但使用MIME类型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屋!

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