【发布时间】:2015-06-14 04:44:46
【问题描述】:
我正在使用 sass 开始一个项目,我更喜欢用 .sass 语法编写它。
我还想使用map 功能来声明一些key-value 变量...
例如:
$primary-colors: (
"red": "#ff0000",
"green": "#00ff00",
"blue": "#0000ff"
);
/* Key and value together */
@each $color in $primary-colors {
.thing {
content: "#{$color}";
}
}
/* Key and value separate */
@each $color-name, $color-code in $primary-colors {
.color-#{$color-name} {
background: $color-code;
}
}
我的问题是我找不到如何用.sass 语法编写那些map 变量。
我已经尝试过类似的方法:
$primary-colors: (
"red": "#ff0000"
)
$example: map-get($primary-colors, "red")
当我尝试编译时出现此错误:
Error: Illegal nesting: Nothing may be nested beneath variable declarations.
我的 sass 版本是:
Sass 3.4.11 (Selective Steve)
有人知道如何像.sass 语法那样使用它吗?
【问题讨论】:
标签: sass compass-sass