Can't get less.js to work
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&g开发者_如何学Got;
</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.
Soruce
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.
But what we could do is setting up a local testing environment using wamp (pc) or mamap (mac). It will work alright then.
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.
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/
Need to add
type="text/css"
to your css link.
精彩评论