2
也許更好的問題是,是否有一個更有效的方法來覆蓋部分mixin?SASS可以合併屬性嗎?
這片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;
}
我的mixin實際上比我的例子複雜得多。我添加了更多的覆蓋,而不僅僅是一種顏色變化。所以從這方面來說,增加參數會讓事情變得太難。如果存在某種@ merge-properties {}函數,它會很好。 – thomasdecrick