我试图制作一个获取参数(可以是变量列表)的mixin,然后在列表的最后一项之后不输出逗号。这是迄今为止的mixin:
@mixin i-class($name...,$pua) {
@if type-of($name) == "list" {
@for $className from 1 through length($name) {
.#{$classIcon}.#{$className}:before,
}
{ content: "\e#{$pua}";}
}
}
@else {
.#{$classPrefix}.#{$name}:before {
content: "\e#{$pua}";
}
}
}
如果像这样传递一个参数,这将是所需的输出:
@include i-class(someIcon,"000");
.icon.someIcon:before {
content: "\e000";
}
如果传递了多个参数(一个列表),那么输出将是这样的:
@include i-class(someIcon,someIcon2,someIcon3,"001");
.icon.someIcon:before, .icon.someIcon2:before, .icon.someIcon3:before {
content: "\e001";
}
我只是不知道用什么来检查它是否是列表中的最后一项,然后省略逗号。帮助将不胜感激:)