Javascript 较少的混入循环类,但具有不同的值

Javascript 较少的混入循环类,但具有不同的值,javascript,jquery,css,less,Javascript,Jquery,Css,Less,我有这个混音器: .myClass { .nth(1); .nth(2); .nth(@i) { &:nth-of-type(@{i}) { transition-delay: 0.2s; } } } 这是以如下方式编译的: .myClass:nth-of-type(1) { transition-delay: 0.2s; } .myClass:nth-of-type(2) {

我有这个混音器:

.myClass {
        .nth(1);
        .nth(2);
    .nth(@i) {
        &:nth-of-type(@{i}) {
            transition-delay: 0.2s;
        }
    }
}
这是以如下方式编译的:

.myClass:nth-of-type(1) {
  transition-delay: 0.2s;
}
.myClass:nth-of-type(2) {
  transition-delay: 0.2s;
}
.myClass:nth-of-type(1) {
  transition-delay: 0.5s;
}
.myClass:nth-of-type(2) {
  transition-delay: 0.02s;
}
我的问题是如何为
转换延迟添加不同的值,因为在这种形式中,将重复相同的值,我需要能够添加不同的值并编译如下内容:

.myClass:nth-of-type(1) {
  transition-delay: 0.2s;
}
.myClass:nth-of-type(2) {
  transition-delay: 0.2s;
}
.myClass:nth-of-type(1) {
  transition-delay: 0.5s;
}
.myClass:nth-of-type(2) {
  transition-delay: 0.02s;
}

依此类推……

由于您不使用循环,而只是使用所需的数字调用mixin,因此您可以在mixin定义中为延迟值添加一个额外的参数,并像下面的代码块中那样使用它:

.myClass{
.nth(1;0.2s);
.nth(2;0.5s);
.n(@i;@delay){
&:第n个类型(@{i}){
转换延迟:@延迟;
}
}
}
或者您可以使用循环和数组,如下面的代码块中所示:(我建议这样做,因为您不需要多次mixin调用。)

@延迟:0.2s、0.5s、0.75s;
.myClass{
(@i>0)时的.n次循环(@i;@delays){
@延迟:提取(@delays,@i);/*从数组中获取元素号对应的延迟值*/
&:第n个类型(@{i}){
转换延迟:@延迟;
}
.n次循环(@i-1;@delays);
}
.n循环(3;@延迟);
}

你必须修改你的混音,将延迟作为一个参数(或者)用一些数学来计算延迟(比如第一个元素1s,第二个元素2s等意味着@i*1s)。@Harry是的,但我真的不知道怎么做:))可能使用索引和除法……哪一个?前者还是后者?
转换延迟
值有模式吗?@Harry transition delay没有模式