我想以模块化方式使用SASS.在下面的代码段中,您可以看到我考虑组织页面的某些布局的方法.
// 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;
}
Run Code Online (Sandbox Code Playgroud)
Sim*_*ias 23
是的,这就是它的工作原理.
只要_colors.scss是在导入其他文件之前.
你可以在这里查看Twitter Bootstrap到Sass的端口:https://github.com/thomas-mcdonald/bootstrap-sass它以类似的方式使用变量.