现在假设我们写了两个less文件,一个文件是a.less 另一个文件是 b.less;
那么a.less文件中如何引用b.less中的文件呢?
例子: 先新建如下的目录结构
文件信息:
index.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>@import</title>
<link rel="stylesheet" href="sty.css">
</head>
<body>
less 的使用;
一个less文件引用另一个less文件
</body>
</html>
a.less
@import "b.less";
body{
background-color:@bg-color;
}
div{
width:unit(@div-len,px);
height:unit(@div-len,px);
background-color:@div-bg;
}
b.less
@bg-color:#ffaabb;
@div-bg:#ffcc44;
@div-len:100;
在上面的文件中,我们在a.less 中使用了 @import “” 引入了b.less文件;
在编译的时候,只需要编译a.less即可,即命令:lessc a.less sty.css ;