我想以模塊化的方式使用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;
}
這應該只是工作。我在我的所有項目中都沒有任何問題地使用它。如果您看到錯誤,則發生其他問題。 –
這仍然不適合我。它似乎需要在使用它的文件內。 – chovy
@SimonBoudrias你怎麼知道「錯誤與實際問題無關」?如果OP忽略了包含分號,那麼問題應該作爲印刷錯誤被關閉。如果存在分號,那麼該問題仍然應該被關閉爲「不可重現」。 – cimmanon