Sass:声明只能在样式规则中使用

  • 本文关键字:规则 样式 声明 Sass sass
  • 更新时间 :
  • 英文 :


我得到一个sass错误:声明只能在样式规则中使用。

╷
32 │     #{$property}: $value;
│     ^^^^^^^^^^^^^^^^^^^^

对于以下文件:

@mixin theme($colour, $texture: null) {
$theme: map-get-strict($themes, $colour, "theme");
@if ($texture) {
@include getTexture($texture);
}
@each $property, $value in $theme {
#{$property}: $value;
}
}

这是用飞镖。

我认为可能是Sass测试文件导致了问题,例如:

@include it('outputs the light-blue theme') {
@include assert {
@include output {
@include theme(light-blue);
}
@include expect {
background-color: getColour(light-blue);
color: getColour(black);
}
}
}

声明只能在样式规则中使用。

您只能在样式规则中使用声明。这意味着,如果您有一个包含声明的mixin

例如:

@mixin foo() {
color: #000;
}

您只能将其包含在样式规则中。

例如:

.bar {
@include foo();
}

这有助于确保编译的CSS没有错误。


颜色:#000

.bar {
color: #000;
}

最新更新