@size: small, large;
@smallWidth: 24px;
@largeWidth: 40px;
// @n > 0 表示@n等于或小于0就结束
.size-loop(@n) when (@n > 0) {
// 从@size中取第@n个。
// 注意:从1开始,并不是数组中的从0开始
@s: extract(@size, @n);
// 这里拼接变量名
@w: '@{s}Width';
// 通过@{s}的方式拼接class名
.input_@{s}{
.input{
// @@w表示根据@w的值获取变量
width: @@w;
}
}
.size-loop(@n - 1);
}
// 传入@size的length
.size-loop(length(@size));