SASS mixins-@content的默认值
是否可以像使用参数一样为SASS mixins-@content的默认值,sass,Sass,是否可以像使用参数一样为@content定义默认值 例如: @mixin foo { @content: width:100%; } 试试这个: @mixin foo($content: 100%) { width:$content; } 或者这个: @mixin foo() { $content: 100%; width:$content; } 不,@content不是变量。不能为其设置默认值。您不能操纵或检查它 如果Ale
@content
定义默认值
例如:
@mixin foo {
@content: width:100%;
}
试试这个:
@mixin foo($content: 100%) {
width:$content;
}
或者这个:
@mixin foo() {
$content: 100%;
width:$content;
}
不,
@content
不是变量。不能为其设置默认值。您不能操纵或检查它
如果Alessandro的答案不适合您的需要,您需要创建一个额外的混音来获得您想要的结果:
@mixin foo {
color: red;
@content;
}
@mixin empty-foo {
@include foo {
width: 100%;
}
}
.foo {
@include foo {
border: 1px solid;
}
}
.bar {
@include empty-foo;
}
对不起,这不是我的意思