Scss @error

css yekong 824℃

@error 和 @warn、@debug 功能是如出一辙。

@mixin error($x){
  @if $x < 10 {
    width: $x * 10px;
  } @else if $x == 10 {
    width: $x;
  } @else {
    @error "你需要将#{$x}值设置在10以内的数";
  }

}

.test {
  @include error(15);
}

编译的时候:

@mixin error($x){ @if $x < 10 { width: $x * 10px; } @else if $x == 10 { width: $x; } @else { @error "你需要将#{$x}值设置在10以内的数"; } } .test { @include error(15); }
喜欢 (1)