如果我有一个LESS参数mixin,例如:
.trans (@what: all, @time: 0.2s, @type: ease-in-out) {
-webkit-transition: @arguments;
-moz-transition: @arguments;
-o-transition: @arguments;
-ms-transition: @arguments;
transition: @arguments;
}
Run Code Online (Sandbox Code Playgroud)
它按预期工作:
.myItem {
.trans;
}
Run Code Online (Sandbox Code Playgroud)
但是如果我想将@time设置为0.4s,我似乎也必须传递第一个项目的参数:
.trans(all, 0.4s);
Run Code Online (Sandbox Code Playgroud)
是否有传递空参数的语法,因此只使用默认值("all")?这不起作用,在编译时抛出错误:
.trans(,0.4s);
Run Code Online (Sandbox Code Playgroud)
谢谢.
bra*_*tin 11
可能为时已晚,但回应可能对其他人有用.
您还可以在调用mixin时命名变量,而无需遵循顺序.
考虑你的情况:
.trans (@what: all, @time: 0.2s, @type: ease-in-out) {
-webkit-transition: @arguments;
-moz-transition: @arguments;
-o-transition: @arguments;
-ms-transition: @arguments;
transition: @arguments;
}
Run Code Online (Sandbox Code Playgroud)
你可以这样做.trans(@time:1s);
或.trans(@type:linear, @what: opacity);
希望能帮助到你.
归档时间: |
|
查看次数: |
3241 次 |
最近记录: |