代码之家  ›  专栏  ›  技术社区  ›  localhost

mixin不输出@each函数

  •  1
  • localhost  · 技术社区  · 7 年前

    我正在尝试@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)
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   Sam Willis blabla test    7 年前

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

    @include themes($buttons)