【发布时间】:2016-01-15 20:59:50
【问题描述】:
我想以模块化的方式使用 SASS。在下面的代码段中,您可以看到我考虑组织页面布局的一种方式。
我想到的是external variables in languages like C。
// file: some_page.scss
//
// I want some variables from the fonts, colors partials
// to be visible to the buttons partial
// Is it possible?
// error: _buttons.scss (Line X: Undefined variable: "$color_blue")
@import "colors"
@import "fonts"
@import "buttons"
// in file: _colors.scss
$color_blue: blue;
// in file: _buttons.scss
.button {
background-color: $color_blue;
}
【问题讨论】:
-
这应该可以。我在所有项目中都使用它,没有任何问题。如果您看到错误,则说明有其他问题。
-
这对我仍然不起作用。似乎变量需要在使用它的文件中。
-
@SimonBoudrias 你怎么知道“错误与实际问题无关”?如果 OP 忽略包含分号,那么问题应该作为印刷错误关闭。如果分号存在,则问题仍应关闭为“不可重现”。
-
@cimmanon 示例代码中的语法错误与所提出的问题无关。
-
@SimonBoudrias 并且修复语法错误不会产生问题中声称的错误。事实上,它根本不会产生错误。
标签: sass