2017-09-16 80 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);