scss 创建数组 1 到 100 而不是字面写

scss create array 1 to 100 without writing it litteraly

所以我有这个 mixin:

@mixin generateSpacings($prefix, $property) {
    $sizes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32];
...

而且显然这样写这个数组很丑陋而且不易维护,我怎么能以编程方式编写它?

Codepen

我会寻求一种解决方案,通过 @for 循环生成数组,然后将其附加到列表中。

$start: 1;
$end: 100;

$array: "";

// array[1] = "", so $start + 1 to later set `""` to $start
@for $i from $start + 1 through $end {
  $array: append($array, $i, comma);

  //set `""` to $start
  $array: set-nth($array, 1, $start);
}