Angular 4 - Material Theme定制

时间:2018-03-17 18:30:50

标签: css angular sass

我试图在Angular Material中设置我的自定义主题。我的问题是当我想导入mixin angular-material-theme时,我收到了这个错误:

  

错误   ./node_modules/raw-loader!./node_modules/postcss-loader/lib??embedded!./node_modules/sass-loader/lib/loader.js??ref--8-3!./src/theme.scss   模块构建失败:未定义            ^         $map的参数map-get($map, $key)必须是地图

     

回溯:           node_modules/@angular/material/_theming.scss:1166,在函数map-get中           node_modules/@angular/material/_theming.scss:1166,在函数mat-color中           node_modules/@angular/material/_theming.scss:1325,in mixin mat-option-theme           node_modules/@angular/material/_theming.scss:3739,在mixin mat-core-theme中           node_modules/@angular/material/_theming.scss:3808,在mixin angular-material-theme中           标准输入:12         在E:\ PC_SHOP \ pcShop-Final \ PcShop-Final \ node_modules \ @angular \ material_theming.scss   (第1166行,第11栏)

我的代码:

@import "~@angular/material/prebuilt-themes/indigo-pink.css";
@import '~@angular/material/_theming.scss';

@include mat-core();

$primary: mat-pallete($mat-orange, 500);
$accent: mat-palette($mat-blue-grey, 800);
$warn: mat-palette($mat-pink, 400);

$app-theme: mat-light-theme($primary, $accent, $warn);

@include angular-material-theme($app-theme);

1 个答案:

答案 0 :(得分:1)

只是一个错字,这就是为什么它没有映射到一种颜色并且你得到了这个错误(你有pallete而不是{{ 1}})。应该是:

palette