📅  最后修改于: 2021-01-06 04:41:14             🧑  作者: Mango
较少参数混合是一种特殊的混合,其中一个或多个参数用于通过获取参数及其属性来扩展Less的功能,并在混合到另一个块中时自定义混合输出。
让我们看一个参数混合的例子:
.border(@width; @style; @color) {
border: @width @style @color;
}
.myheader {
.border(5px; dashed; red);
}
在这里,参数混合是边框,具有三个参数,分别是宽度,样式和颜色。这些参数用于根据传递的参数值来自定义mixin输出。
不同类型的参数混合的列表:
Index | Types | Explanation |
---|---|---|
1) | Mixins with Multiple Parameters | In this type of mixins, parameters can be separated using commas or semicolon. |
2) | Named Parameters | In Named Parameters, mixins provides parameters values instead of positions by using their names. |
3) | @arguments Variable | @arguments variable includes all the passed arguments when mixin was called. |
4) | Advanced Arguments and the @rest Variable | Mixin takes variable number of arguments by using ….. |
5) | Pattern-matching | Pattern-matching is used change the behavior of mixin by passing parameters to it. |