javascript LESS CSS 最小设置失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7942277/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
LESS CSS minimal setup failure
提问by cYrus
Looking at the quick start on the official siteI wrote:
查看我写的官方网站上的快速入门:
less.html
少.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;
}
both locally, and all I get is (from Google Chrome console):
在本地,我得到的只是(来自 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 answershows a way to overcome this:
$ google-chrome -allow-file-access-from-files
采纳答案by nheinrich
The less.js script currently doesn't work if you're using Chrome and the path to your page starts with “file:///”.
如果您使用的是 Chrome 并且您的页面路径以“file:///”开头,则less.js 脚本当前不起作用。
There is also a SO question with the same info here: less.js not working in chrome
这里还有一个具有相同信息的 SO 问题:less.js not working in chrome
回答by WooCaSh
Another way is use script from CDN. For example: http://cdnjs.com/
另一种方法是使用 CDN 中的脚本。例如:http: //cdnjs.com/
For me this solve that problem.
对我来说,这解决了这个问题。
回答by DEVPROCB
The best way to load this locally is to run the local site in xampp or wamp, which gets around all of that. You will no longer get these errors when doing this. This would be the best route for this issue.
在本地加载它的最佳方法是在 xampp 或 wamp 中运行本地站点,这可以解决所有这些问题。执行此操作时,您将不再收到这些错误。这将是解决此问题的最佳途径。