mixin调用中的SCSS插值

时间:2012-10-31 15:27:35

标签: css sass

我想在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;

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

1 个答案:

答案 0 :(得分:0)

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

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

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

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