0
我想將sass mixin參數化,以使其他mixin作爲參數在名稱範圍內擴展。sass包含mixin作爲參數
@mixin c(){color:red}
@mixin view($param){*{@include #{$param}}}
div{@include view}
第二行和它的變體我用盡不工作,我還沒有找到任何辦法變量傳遞到@include條款
我想將sass mixin參數化,以使其他mixin作爲參數在名稱範圍內擴展。sass包含mixin作爲參數
@mixin c(){color:red}
@mixin view($param){*{@include #{$param}}}
div{@include view}
第二行和它的變體我用盡不工作,我還沒有找到任何辦法變量傳遞到@include條款
你可以嘗試添加里面混入了一些條件:
@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);
}
可能重複[在SASS中傳遞函數或引用mixin](http://stackoverflow.com/questions/14295595/pass-function-or-mixin-by-reference-in-sass) – cimmanon