如何将精灵名称列表传递给sass + compass中的mixin

时间:2015-02-24 19:22:43

标签: sass sprite compass

我有这样的混音:

@mixin sprite-icon-pos-each() {

    $icons: sprite-map("icons/*.png", $spacing: 1px);
    $icon-names: "vk", "fb", "tw", "gp", "ok";

    @each $item in $icon-names {
        &_tp_#{$item} {
            @include sprite-icon-pos($item);
            }
            &_tp_#{$item}:hover {
                @include sprite-icon-pos(#{$item}_hover);
                }
    }

} 

它的工作正常,但是 当我包括mixin时,如何设置$icon-names: "vk", "fb", "tw", "gp", "ok"。像这样:

@mixin sprite-icon-pos-each($icons) {

    $icons: sprite-map("icons/*.png", $spacing: 1px);

    @each $item in $icon-names {
        &_tp_#{$item} {
            @include sprite-icon-pos($item);
            }
            &_tp_#{$item}:hover {
                @include sprite-icon-pos(#{$item}_hover);
                }
    }

}

.some-selector {
    @include sprite-icon-pos-each($icon-names: "vk", "fb", "tw", "gp", "ok");
}

当我这样做时,指南针发生错误“位置参数必须在关键字参数之前出现”。

1 个答案:

答案 0 :(得分:0)

我弄清楚为什么它不起作用。 Аrguments必须括在括号中:

@include sprite-icon-pos-each($icon-names: ("vk", "fb", "tw", "gp", "ok"));