示例代码(我知道可以重写什么以避免级联,但我将其编写为示例。这段代码不是真正的问题,我可以用另一种方式解决,这只是说明):
.b-list {
//…
&__item {
//…
}
&__link {
height: 4px;
//…
@at-root .b-list__item.-active & {
height: 12px;
}
}
}
它被编译为:
.b-list__link {
height: 4px;
}
.b-list__item.-active .b-list__link {
height: 12px;
}
我想将选择器更改为@at-root .b-list__item.-active &
类似@at-root &__item.-active & {…}
避免重复父类名的东西,但它在 Sass 中不起作用:
此代码不起作用:
.b-list {
//…
&__item {
//…
}
&__link {
height: 4px;
//…
@at-root &__item.-active & {
height: 12px;
}
}
}
那么,有办法做我想做的事吗?