【发布时间】:2021-06-22 08:21:29
【问题描述】:
我在使用 gulp-sass 的项目中遇到了这个 mixin 的问题:
$base-font-stack: (
sfprodisplay: (
regular: (
family: (SFProDisplay, sans-serif),
weight: 400,
style: normal
),
bold: (
family: (SFProDisplay, sans-serif),
weight: 700,
style: normal
),
),
ubuntu: (
light: (
family: (Ubuntu, sans-serif),
weight: 300,
style: normal
),
regular: (
family: (Ubuntu, sans-serif),
weight: 400,
style: normal
),
)
);
@mixin font($group, $variant: regular, $properties: family weight style, $font-stack: $base-font-stack) {
$font-properties: map-deep-get($font-stack, $group, $variant);
@if $font-properties {
@each $property, $values in $font-properties {
@if contains($properties, $property) {
font-#{$property}: map-get($font-properties, $property);
}
}
}
}
这不是重复的问题,问题是:
我在 sassmeister 中检查了这一点,并在这行得到了错误:
$font-properties: map-deep-get($font-stack, $group, $variant);
font-#{$property}: map-get($font-properties, $property);
在尝试编译最后一行时,gulp-sass 会抛出错误。
【问题讨论】:
-
不,我的 mixin 和 map 命令有问题。
-
我的错,我将属性误读为变量。 :)
-
@Andy,不确定你是否已经找到了解决方案,但我留下了一个答案——包括 Node-Sass 和 Dart-Sass。
标签: sass gulp-sass scss-mixins