也许更好的问题是,是否有更有效的方式来覆盖mixin的部分?
这篇SCSS:
@mixin button {
.button {
background-color: red;
color: white;
}
}
.container {
@include button;
.button {
background-color: green;
}
}
汇编为:
.container .button {
background-color: red;
color: white;
}
.container .button {
background-color: green;
}
我希望它能编译成:
.container .button {
background-color: green;
color: white;
}
答案 0 :(得分:3)
将参数传递给mixin:
@mixin button($color: red) {
background-color: $color;
color: white;
}
.container {
.button {
@include button(green);
}
}