CSS最小化设置失败

cYr*_*rus 17 html javascript css google-chrome less

看一下我写的官方网站上的快速入门:

less.html

<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet/less" type="text/css" href="style.less" />
    <script src="less-1.1.3.min.js" type="text/javascript"></script>
  </head>
  <body>
    <h1>foo</h1>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

style.less

@color: red;

h1 {
  color: @color;
}
Run Code Online (Sandbox Code Playgroud)

在本地,我得到的是(来自谷歌Chrome控制台):

XMLHttpRequest cannot load file:///home/cyrus/test/style.less. Cross origin requests are only supported for HTTP.
Uncaught Error: NETWORK_ERR: XMLHttpRequest Exception 101
    r
    o
    n
    d.refresh
    (anonymous function)
    (anonymous function)

解决方法:

这个答案显示了克服这个问题的方法:

$ google-chrome -allow-file-access-from-files
Run Code Online (Sandbox Code Playgroud)

nhe*_*ich 17

如果您使用Chrome并且页面路径以"file:///"开头,则less.js脚本目前无效.

这里也有一个SO问题相同的信息:less.js不能用于chrome