Sass映射动态键



是否可以使用变量作为键来定义映射?

示例代码

$types: (
'INPUT': 1,
'SELECT': 2,
'BUTTON': 3,
);
$colors: (
$types['INPUT'] : #f44336,
$types['SELECT']: #2196f3,
$types['BUTTON']: #9c27b0,
);

我发现了如何进行

@function type($key) {
@return map-get($types, $key);
}
$colors: (
type('INPUT'): #f44336,
type('SELECT'): #2196f3,
type('BUTTON'): #9c27b0,
}

最新更新