1- map的数据结构,类似json

  1. $colors:(
  2. success:#398439,
  3. warning:#ec971f,
  4. danger:#c9302c
  5. );
  6. .btn-danger{
  7. background-color: map-get($map: $colors, $key:danger );
  8. }

2- @function 定义了一个颜色函数

  1. $colors:(
  2. success:#398439,
  3. warning:#ec971f,
  4. danger:#c9302c
  5. );
  6. @function color($key){
  7. @return map-get($map:$colors , $key: $key)
  8. };
  1. .btn-danger{
  2. background-color: color(danger);
  3. }
  4. .btn-success{
  5. background-color: color(success);
  6. }