我有 .less 文件:
@flag1: fr;
@flag2: en;
@flag3: ru;
@iterations: 3;
.loopingClass (@index, @difference: 0) when (@index < @iterations) {
@idx: (@index + 1);
@diff: (@difference - 32);
(~".my-class-@{index}") {
my-idx: @idx;
my-diff: @diff;
my-index: @index;
my-difference: @difference;
}
.loopingClass(@idx, @diff);
}
.loopingClass (@iterations) {}
.loopingClass (0);
它怎么会在哪里生成我 .css@idx
并且@diff
始终是循环的最后一个值?
.my-class-0 {
my-idx: 3;
my-diff: -96;
my-index: 0;
my-difference: 0;
}
.my-class-1 {
my-idx: 3;
my-diff: -96;
my-index: 1;
my-difference: -32;
}
.my-class-2 {
my-idx: 3;
my-diff: -96;
my-index: 2;
my-difference: -64;
}
我不太擅长使用更少,但我尽了最大努力并尝试了很多方法来让这个循环正常工作。我需要@idx
并且@diff
成为 1、2、3 和 -32、-64、-96。