2017-09-16 44 views
0

我正在使用@角/材料@ 2.0.0 beta.10角材料主題化:消耗另一個SCSS文件主題定義對象

Angular Material Document在角4.3.6編碼說

如果您希望在其他SCSS文件中使用主題定義對象(例如, $ candy-app-theme),那麼 主題對象的定義應該分解爲它自己的文件,與包含mat-core的 分開和角材料主題混搭。

如何將其歸檔?具體而言,我在我的頂級scss中有以下內容:

@import '[email protected]/material/theming'; 
// Include non-theme styles for core. 
@include mat-core(); 
$primary: mat-palette($mat-indigo, 400, 100, 900); 

如何使$ primary在其他scss文件中可用?

在過去,我遍地都是@include mat-core()。我只注意到,

這應該只包括一次在您的應用程序。

應該怎麼做才能在其他scss文件中映射獲取($ primary)?

回答

0

我通過試用找到了答案。

只要按照指示信去做,別做任何事情:請勿在最頂端的scss以外的任何其他位置使用@includemat-core()

您被允許@import[email protected]/material/theming多次。 在每個scss腳本中,你需要mat-palette$mat-indigo,@import它。

// on other scss other than the root one, @import as usual 
@import '[email protected]/material/theming'; 
// @include mat-core(); but don't @include this again 
$primary: mat-palette($mat-indigo, 400, 100, 900);