无法让 less.js 工作
我无法让 less.js 工作,我不知道为什么。这是我尝试过的 HTML:
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8" />
<!-- CSS -->
<link rel="stylesheet/less" href="main.less" />
<!-- Javascript -->
<!-- <script src="http://lesscss.googlecode.com/files/less-1.0.18.min.js"></script> -->
<script src="less-1.0.18.min.js" type="text/javascript"></script>
</head>
<body>
<p>
Lorum ipsum
</p>
</body>
</html>
这是 main.less:
p {
color: blue;
}
less-1.0.18.min.js 文件是从 http://lesscss.googlecode.com/files/less-1.0.18.min.js。所有文件都位于同一文件夹中。我不知道为什么这不起作用...
在 Chrome 12.0.742.100 中测试
编辑
尝试了最新的 less.js 文件 (less-1.1.3.min.js)。那个也不起作用。
现在好了...
这有效:
<link rel="stylesheet" type="text/less" href="main.less" />
但只能作为普通的 css,没有更具体的标记。
这根本不起作用:
<link rel="stylesheet/less" type="text/less" href="main.less" />
另外,这不起作用:
<link rel="stylesheet/less" type="text/css" href="main.less" />
到底是什么?我怎样才能减少工作时间?
发现错误
如果您使用 Chrome,并且由于已知的 Chrome 问题,页面路径以“file:///”开头,PSS Less.js 浏览器脚本目前将无法工作。
I can't get less.js to work and I have no idea why. Heres the HTML i tried:
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8" />
<!-- CSS -->
<link rel="stylesheet/less" href="main.less" />
<!-- Javascript -->
<!-- <script src="http://lesscss.googlecode.com/files/less-1.0.18.min.js"></script> -->
<script src="less-1.0.18.min.js" type="text/javascript"></script>
</head>
<body>
<p>
Lorum ipsum
</p>
</body>
</html>
And heres main.less:
p {
color: blue;
}
The less-1.0.18.min.js file is downloaded from http://lesscss.googlecode.com/files/less-1.0.18.min.js. All files is in the same folder. I have no idea why this isn't working...
Tested in Chrome 12.0.742.100
Edit
Tried the lates less.js file (less-1.1.3.min.js). That one did also not work.
Okay now...
This works:
<link rel="stylesheet" type="text/less" href="main.less" />
But only as normal css, no less specific markup.
This doesn't work at all:
<link rel="stylesheet/less" type="text/less" href="main.less" />
Also, this isn't working:
<link rel="stylesheet/less" type="text/css" href="main.less" />
What the hell? How do I get less to work?
Found the error
P.S.S. Less.js browser script currently won’t work if you’re using Chrome and the path to your page starts with “file:///” due to a known Chrome issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
但我们可以做的是使用 wamp (pc) 或 mamap (mac) 设置本地测试环境。然后就可以正常工作了。
But what we could do is setting up a local testing environment using wamp (pc) or mamap (mac). It will work alright then.
启动 chrome 时,您可以使用命令行开关 -allow-file-access-from-files - 它将允许 less.js 访问本地 less 文件。
You can use the command-line switch -allow-file-access-from-files when starting chrome - it will permit less.js to access local less files.
尽管这是不久前发布的,但我想我应该为其他坚持于此的人添加一些东西。
如果您使用 Windows 计算机,您可能想尝试一下 WinLess。它是 Windows 的预编译器。看起来很容易使用。祝你好运。
http://winless.org/
Even though this was posted a while ago I thought I would add a little something for other people stuck on this.
If you use a windows machine, you might want to give WinLess a try. Its a pre-compiler for windows. Seems straight forward to use. Good luck.
http://winless.org/
需要添加
到你的 css 链接。
Need to add
to your css link.