首页 文章

角度材料主题:在另一个scss文件中使用主题定义对象

提问于
浏览
0

我使用@ angular / material @ 2.0.0-beta.10在Angular 4.3.6中编码

Angular Material Document

如果你想在其他SCSS文件中使用主题定义对象(例如,$ candy-app-theme),那么主题对象的定义应该被分解为它自己的文件,与包含mat-core和角度材料主题混合 .

我如何存档?具体来说,我在顶级scss中有以下内容:

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

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

在过去,我@include mat-core()无处不在 . 我注意到这一点,只是一点点

这应该只包含在您的申请中一次 .

应该怎么做才能在其他scss文件中map-get($ primary)?

1 回答

  • 0

    我通过试验找到了答案 .

    只需按照信中的说明操作,别做其他事情:不要在最顶层的scss以外的任何其他位置 @include .

    您可以多次 @import ~@angular/material/theming . 在每个scss脚本中,您需要再次使用 mat-palette$mat-indigo@import .

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

相关问题