学员端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
640 B

1 year ago
  1. // 合并 map
  2. @function map-deep-merge($parent-map, $child-map){
  3. $result: $parent-map;
  4. @each $key, $child in $child-map {
  5. $parent-has-key: map-has-key($result, $key);
  6. $parent-value: map-get($result, $key);
  7. $parent-type: type-of($parent-value);
  8. $child-type: type-of($child);
  9. $parent-is-map: $parent-type == map;
  10. $child-is-map: $child-type == map;
  11. @if (not $parent-has-key) or ($parent-type != $child-type) or (not ($parent-is-map and $child-is-map)){
  12. $result: map-merge($result, ( $key: $child ));
  13. }@else {
  14. $result: map-merge($result, ( $key: map-deep-merge($parent-value, $child) ));
  15. }
  16. }
  17. @return $result;
  18. };