网站搜索

typescript - 使用 Angular Materials 定义自定义主题时的 SassError


我正在尝试使用此处描述的指南为 Angular Materials 创建自定义主题:https://material.angular.io/guide/theming#defining-a-custom-theme

但是当我定义浅色主题的颜色时会出现错误:以下是代码:

@import '~@angular/material/theming';
// Plus imports for other components in your app.

// Include the common styles for Angular Material. We include this here so that you only
// have to load a single css file for Angular Material in your app.
// Be sure that you only ever include this mixin once!
@include mat-core();

// Define the palettes for your theme using the Material Design palettes available in palette.scss
// (imported above). For each palette, you can optionally specify a default, lighter, and darker
// hue. Available color palettes: https://material.io/design/color/
$candy-app-primary: mat-palette($mat-indigo);
$candy-app-accent:  mat-palette($mat-pink, A200, A100, A400);

// The warn palette is optional (defaults to red).
$candy-app-warn:    mat-palette($mat-red);

// Create the theme object. A theme consists of configurations for individual
// theming systems such as `color` or `typography`.
$candy-app-theme: mat-light-theme((
  color: (
    primary: $candy-app-primary,
    accent: $candy-app-accent,
    warn: $candy-app-warn,  
  )
));

// Include theme styles for core and each component used in your app.
// Alternatively, you can import and @include the theme mixins for each component
// that you are using.
@include angular-material-theme($candy-app-theme);

我得到的错误是这样的:

错误在 ./src/styles.scss (./node_modules/css-loader/dist/cjs.js??ref--13-1!./node_modules/postcss-loader/src??embedded!./node_modules/resolve-url-loader??ref--13-3!./node_modules/sass-loader/dist/cjs.js??ref--13-4!./src/styles.scss) 模块构建失败 (来自 ./node_modules/sass-loader/dist/cjs.js): SassError: 函数 mat-light-theme 缺少参数 $accent。位于 src/styles.scss 的第 17 行

$candy-app-theme: mat-light-theme(( ------------------^任何帮助都将不胜感激。

答案#1

尝试使用

npm rebuild node-sass