Sass" @ at-root"不工作

时间:2014-03-28 12:46:05

标签: sass

目前我已经安装了sass 3.3但我正在使用指南针进行编译。手头的问题是,我有以下两个mixin来做bem语法:

//elements get appended with "__" and the $name
=e($name)
    @at-root &__#{$name}
        @content

//modifiers get appended with "--" and the $name
=m($name)
    @at-root &--#{$name}
        @content

使用中:

.blocker
    +e(item)
        color: red

输出:

.blocker {
  @at-root &__item {
    color: blue;
}

}

为什么不起作用?

1 个答案:

答案 0 :(得分:1)

我尝试了你的mixin似乎工作正常,但是,使用更新的sass语法,你不需要mixin或@to-root来实现这个

.blocker
    &__item
        color: red 
    &--mod
        color: blue

将编译为

.blocker__item {
    color: blue;
}
.blocker--mod {
    color: red;
}

如果您想独立于您的环境尝试sass代码本身,请查看SassMeister