为什么LESS css不能在localhost上运行

Hel*_*rld 4 html css localhost less

根据本教程,我的代码应该少,但事实并非如此.

你能帮助我减少工作量吗?

现在它无法正常工作 - 没有应用样式的页面加载.我究竟做错了什么?

错误是:

FileError:在styles.less中找不到'localhost:1/styles.less'(404)

但它存在于根源中吗?

HTML

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <title></title>
    <link rel="stylesheet/less" type="text/css" href="styles.less">
    <script src="_/script/less-1.4.1.min.js" type="text/javascript"></script>

</head>

<body>

    <div id="header">test</div>

    <h2>test h2</h2>

</body>

</html>
Run Code Online (Sandbox Code Playgroud)

styles.less

@color: red;

#header {
    color: @color;
}
h2 {
    color: @color;
}
Run Code Online (Sandbox Code Playgroud)

小智 11

如果您使用的是IIS,则必须在IIS管理器中为MIME类型添加".less"扩展名.添加新的MIMI时,输入".less"作为扩展名,输入"text/css"作为MIME类型.


AKS*_*AKS 11

假设网站通过iis express托管,请打开该文件

C:\用户\\的文档\ IISExpress \设置\对ApplicationHost.config

并搜索标签
<staticContent lockAttributes="isDocFooterFileName">

并添加.less MIME,如下所示

<mimeMap fileExtension=".latex" mimeType="application/x-latex" />

<mimeMap fileExtension=".less" mimeType="text/css" />

<mimeMap fileExtension=".lit" mimeType="application/x-ms-reader" />