有没有更好的方法来解决这个问题。我的mixin包含开始变得重复,并且不知道是否有更好的方法来执行此操作:
@mixin button-type($name, $bgColor, $borderColor, $color, $hoverBg, $hoverColor) {
.btn-#{$name} {
background-color : $bgColor;
border-color : $borderColor;
color : $color;
&:hover {
background-color : $hoverBg;
border-color : $borderColor;
box-shadow : 0 0 5px rgba(0, 0, 0, .5);
color : $hoverColor;
}
}
}
@include button-type('warning', #fff, $dark-blue, $black, $dark-blue, #fff);
@include button-type('primary', #fff, $dark-blue, $black, $dark-blue, #fff);
@include button-type('active', #fff, $dark-blue, $black, $dark-blue, #fff);
答案 0 :(得分:2)
你可以制作另一个mixin,用你的mixin调用所需属性的硬编码值:
@mixin dark-blue-button-type($name) {
@include button-type($name, #fff, $dark-blue, $black, $dark-blue, #fff);
}
所以称之为:
@include dark-blue-button-type('warning');
@include dark-blue-button-type('primary');
@include dark-blue-button-type('active');