@import './themeVariable.scss'; $theme-map: null; @mixin themify($themes: $themes) { @each $theme-name, $map in $themes { // & 表示父级元素 // !global 表示覆盖原来的 .theme-#{$theme-name} & { $theme-map: () !global; // 循环合并键值对 @each $key, $value in $map { $theme-map: map-merge( $theme-map, ( $key: $value, ) ) !global; } // 表示包含 下面函数 themed() @content; $theme-map: null !global; } } } @function themed($key) { @return map-get($theme-map, $key); }