[英]What does "use this SASS mixin" mean in the context of Material Design Components?
I am using the Material Design Components for Web library.我正在使用Material Design Components for Web库。 I have a tab component that I'd like to change the
underline-color
of.我有一个选项卡组件,我想更改其
underline-color
。
The instructions say说明说
To customize the tab indicator, use the following mixins.
要自定义选项卡指示器,请使用以下混合。
Then it gives a table.然后它给了一张桌子。 For underline color, it says
对于下划线颜色,它说
underline-color($color) Customizes the color of the underline.
underline-color($color) 自定义下划线的颜色。
So, I try in my scss
file, the following:所以,我在我的
scss
文件中尝试以下内容:
.mdc-tab-indicator {
underline-color(red);
}
I compile my sass (using dart-sass
) and get the following error我编译了我的 sass(使用
dart-sass
)并得到以下错误
Error: expected "{".
It says this is a "Sass Mixin."它说这是一个“Sass Mixin”。 So, I look at the SASS documentation on mixins .
因此,我查看了有关 mixins的SASS 文档。 I see nothing that follows the syntax
mixin-name($variable)
.我看不到任何遵循
mixin-name($variable)
语法的内容。 Everything in there looks like里面的一切看起来像
@mixin reset-list {
margin: 0;
}
with curly braces, not parentheses.用花括号,而不是圆括号。 But, the error said it was expecting a curly brace, and also apparently the
@
symbol is required.但是,错误表明它需要一个花括号,而且显然需要
@
符号。 So, I try:所以,我尝试:
.mdc-tab-indicator {
@underline-color(red);
}
This doesn't throw an error, but doesn't cause the underline color to change.这不会引发错误,但不会导致下划线颜色发生变化。 I try to follow the syntax of the sass docs:
我尝试遵循 sass 文档的语法:
.mdc-tab-indicator {
@underline-color(red){};
}
No error, but no color change.没有错误,但没有颜色变化。 I try to match the syntax better:
我尝试更好地匹配语法:
.mdc-tab-indicator {
@mixin underline-color(red){};
}
This throws这抛出
Error: expected ")".
I try我试试
.mdc-tab-indicator {
@mixin underline-color(red);
}
Same error.同样的错误。
I don't understand what the material components documentation is instructing.我不明白材料组件文档在说明什么。 What does it mean when it says "To customize the tab indicator, use the following mixins."
当它说“要自定义选项卡指示器,请使用以下混合”时是什么意思。 ?
? How can I change the underline color of the Material Design Component tab indicator?
如何更改 Material Design 组件选项卡指示器的下划线颜色?
Mixins are defined using the @mixin at-rule, which is written @mixin { ... } or @mixin name() { ... }. Mixin 是使用@mixin at-rule 定义的,它写成@mixin { ... } 或@mixin name() { ... }。 A mixin's name can be any Sass identifier, and it can contain any statement other than top-level statements.
mixin 的名称可以是任何 Sass 标识符,并且可以包含除顶级语句之外的任何语句。 They can be used to encapsulate styles that can be dropped into a single style rule;
它们可用于封装可以放入单个样式规则的样式; they can contain style rules of their own that can be nested in other rules or included at the top level of the stylesheet;
它们可以包含自己的样式规则,这些规则可以嵌套在其他规则中或包含在样式表的顶层; or they can just serve to modify variables.
或者它们可以仅用于修改变量。
Mixins are included into the current context using the @include at-rule, which is written @include or @include (), with the name of the mixin being included.使用@include 规则将mixin 包含到当前上下文中,该规则写作@include 或@include(),其中包含mixin 的名称。
So, to include your specific mixin use:因此,要包括您的特定 mixin 使用:
.mdc-tab-indicator {
@include underline-color(red);
}
See more at https://sass-lang.com/documentation/at-rules/mixin在https://sass-lang.com/documentation/at-rules/mixin查看更多
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.