scss无法使用内置函数(map.get)

tktrz96b  于 2023-04-08  发布在  其他
关注(0)|答案(1)|浏览(315)

list.nth没有导致错误,但map.set是,不知道为什么(新的sass)。

@use "sass:map";
@use "sass:list";

$fontSizes: (200, 300, 400, 500, 600, 700, 800, 900);
@function createFontSizes($baseFontSize, $multiplier) {
    $temp: ();
    @for $i from 1 through length($fontSizes) {
        $current: list.nth($fontSizes, $i);
        map.set($temp, $current, $baseFontSize * $multiplier * $i);
    };

    @return $temp;
}

错误

Error: expected "$".
   ╷
10 │         map.set($temp, $current, $baseFontSize * $multiplier * $i);
   │             ^
   ╵
pgvzfuti

pgvzfuti1#

@use "sass:map";
@use "sass:list";

$fontSizes: (200, 300, 400, 500, 600, 700, 800, 900);
@function createFontSizes($baseFontSize, $multiplier) {
    $temp: ();
    @for $i from 1 through length($fontSizes) {
        $current: list.nth($fontSizes, $i);

        // should assign to the variable
        $temp: map.set($temp, $current, $baseFontSize * $multiplier * $i);
    };

    @return $temp;
}

相关问题