1

我想在 mixin 调用中做一个简单的插值:

$models: "square", "square-green", "circle";
$services: "facebook", "twitter", "linkedin", "gplus", "feed";

@each $model in $models {
    @include all-#{$model}-sprites;
    @each $service in $services {
            #{$model}-#{$service} {
                &:hover{ @extend .#{$model}-#{$service}-hover;};
            }
    }
}

错误 sass/soboo2.scss(第 14 行:“@include all-”之后的无效 CSS:预期的“}”,是“#{$model}-sprites;”)

我还尝试了互联网上的一些语法变体:

@include all-"#{$model}"-sprites;
@include [all-#{$model}-sprites];
@include [all-"#{$model}"-sprites];
@include all-$model-sprites;

不起作用...有什么建议吗?

4

1 回答 1

0

进行 mixin 插值的“正确”方法是这样编写调用:

@include all-#{$model}-sprites(); // parenthesis are optional if 0 arguments given

但是,您应该看看这个答案:

https://stackoverflow.com/a/16153447/10680340

于 2021-05-15T14:33:51.363 回答