【发布时间】:2022-01-27 16:49:03
【问题描述】:
有这样的SCSS代码:
$font-weights: (
"font-weight-thin": 100,
"font-weight-light": 300,
"font-weight-regular": 400,
"font-weight-medium": 500,
"font-weight-bold": 700,
"font-weight-black": 900,
);
@function font-weight($font-weight-style){
@return map-get($font-weights, $font-weight-style);
}
那么我们可以通过如下函数调用的形式来使用它:
.header_top_navigation{
font-weight: font-weight(font-weight-regular);
}
问题:
与使用普通的SCSS 变量相比,这种方法有哪些优势(以及它解决了哪些任务)?
或者它只是一个等效但更混乱的替代方案?
【问题讨论】:
-
对我来说似乎是不必要的开销。