我想参数化 sass mixins,以扩展其他混合作为参数传递,并在其中扩展名称。
@mixin c(){color:red}
@mixin view($param){*{@include #{$param}}}
div{@include view}
我尝试的第二行及其变体不起作用,我还没有找到任何将变量传递到 @include 子句的方法
您可以尝试在mixin中添加一些条件:
@mixin test1(){
color: red;
}
@mixin test2(){
color: blue;
}
@mixin view($param){
.test{
@if $param == 'test1'{
@include test1();
}
@if $param == 'test2'{
@include test2();
}
}
}
div{
@include view(test1);
}