Sass映射动态键
是否可以使用变量作为键来定义映射 示例代码Sass映射动态键,sass,sass-maps,Sass,Sass Maps,是否可以使用变量作为键来定义映射 示例代码 $types: ( 'INPUT': 1, 'SELECT': 2, 'BUTTON': 3, ); $colors: ( $types['INPUT'] : #f44336, $types['SELECT']: #2196f3, $types['BUTTON']: #9c27b0, ); 我知道怎么做了 @function type($key) {
$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,
}