1. 多個顏色管理
~~~
$colors:(
bg:#eee,
text-color:#333,
primary:#ff2d51
);
//自定義函數
@function color($key) {
@if map-has-key($colors, $key) {
@return map-get($colors, $key);
}
@warn "Unknown `#{$key}` in $colors.";
@return null;
}
div{
background: color(bg)
}
//通過自定義的方法來改顏色
div{
color:map-get($map: $colors, $key: text-color)
}
~~~