5-7 @error
本节编程练习不计算学习进度,请电脑登录imooc.com操作

@error

@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);
}

编译的时候:

你需要将15值设置在10以内的数 on line 7 at column 5

 

任务

小伙伴们,现在让我们来练习一下@error的用法吧!

  1. @mixin error($x){
  2. @if $x < 10 {
  3. width: $x * 10px;
  4. } @else if $x == 10 {
  5. width: $x;
  6. } @else {
  7. @error "你需要将#{$x}值设置在10以内的数";
  8. }
  9.  
  10. }
  11.  
  12. .test {
  13. @include error(15);
  14. }
返回课程