Scss @warn

css yekong 518℃

@warn 和 @debug 功能类似,用来帮助我们更好的调试 Sass。如:

@mixin adjust-location($x, $y) {
  @if unitless($x) {
    @warn "Assuming #{$x} to be in pixels";
    $x: 1px * $x;
  }
  @if unitless($y) {
    @warn "Assuming #{$y} to be in pixels";
    $y: 1px * $y;
  }
  position: relative; left: $x; top: $y;
}

调试结果

@mixin adjust-location($x, $y) { @if unitless($x) {//unitless是内置函数,判断数值是否有“单位” @warn "Assuming #{$x} to be in pixels"; $x: 1px * $x; } @if unitless($y) { @warn "Assuming #{$y} to be in pixels"; $y: 1px * $y; } position: relative; left: $x; top: $y; } .botton{ @include adjust-location(20px, 30); }
喜欢 (0)