条件指令(如果)
@if 控制指令评估给定的表达式,如果它返回除 false 以外的任何内容,它将处理其样式块。
Sass 例子
$test-variable: true !default
=test-mixin
  @if $test-variable
    display: block
  @else
    display: none
.test-selector
  +test-mixin
SCSS 示例
$test-variable: true !default
@mixin test-mixin() {
  @if $test-variable {
    display: block;
  } @else {
    display: none;
  }
}
.test-selector {
  @include test-mixin();
}
以上示例生成以下 CSS:
.test-selector {
  display: block;
}