小编Air*_*iro的帖子

v11 到 14 升级后,Angular 自定义材质主题未加载

更新- 主线程帖子底部的解决方案 -

样式.scss

@import "./material";

$pace-red: #bb2d1c;
$green: #008000;
$red: #f00;
$black: #000;

body {
  margin: 0;
}
...
Run Code Online (Sandbox Code Playgroud)

自定义主题 - Material.scss

@use '~@angular/material' as mat;
@import '@angular/material/theming';
@include mat.core();

$core-app-primary: mat.define-palette(mat.$red-palette, A700);
$core-app-accent: mat.define-palette(mat.$blue-palette, 500);
$core-app-warn: mat.define-palette(mat.$amber-palette, 800);
$core-app-theme: mat.define-light-theme($core-app-primary, $core-app-accent, $core-app-warn);

@include mat.all-component-themes($core-app-theme);
...
Run Code Online (Sandbox Code Playgroud)

我收到一条错误消息,指出由于 @use,它无法构建模块。我也尝试过使用@use '~@angular/material' as mat;,但这并没有改变错误。

错误

包.json

{
  "name": "xxxxx-core-cli",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng-high-memory": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng",
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test", …
Run Code Online (Sandbox Code Playgroud)

node-sass angular-material sass-loader angular

0
推荐指数
1
解决办法
2452
查看次数