查看 official site 上的快速启动我写道:
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>
style.less
@color: red;
h1 {
color: @color;
}
在本地,我得到的只是(来自 Google 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)
WORKAROUND:
This answer shows a way to overcome this:
$ google-chrome -allow-file-access-from-files
最佳答案
如果您使用的是 Chrome 且您的页面路径以“file:///”开头,则 less.js 脚本目前无法运行。
这里还有一个具有相同信息的 SO 问题:less.js not working in chrome
关于javascript - LESS CSS 最小设置失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7942277/