首页 > 解决方案 > Mixin 不输出@each 函数

问题描述

我正在尝试@each,它在没有@mixin 的情况下可以正常工作,但是当我使用@mixin 使其灵活时,它不会输出任何内容。我无法弄清楚我错过了什么?

$buttons : (
    default : $color-primary,
    success : #63cc82,
    error   : #e4757e,
    warning : #fd7856,
    info    : #927bc1,
)

混音

@mixin themes($map){
    @each $button, $color in $map {
        &--#{$button}{
            background:$color;
        }
    }
}

我这样称呼它

@include themes(buttons)

标签: sass

解决方案


您需要将地图作为变量传递,如下所示:

@include themes($buttons)

推荐阅读