typescript 自定义排版在更新后无法在角形材料15中工作

cczfrluj  于 2023-01-10  发布在  TypeScript
关注(0)|答案(1)|浏览(105)

这段代码非常适合在我的整个应用程序中使用angular14定制字体

@use '@angular/material' as mat;
@import '@angular/material/theming';

$my-typography: mat-typography-config($font-family: "Lato, sans-serif");

@include mat.core($my-typography);

将角形材料& cdk更新为15时,此错误持续发生:

Error: Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
HookWebpackError: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Only 0 arguments allowed, but 1 was passed.
  ┌──> src\app\core\sass\cecom-theme.scss
11│ @include mat.core($my-typography);
  │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation
  ╵
  ┌──> node_modules\@angular\material\core\_core.scss
8 │ @mixin core() {
  │        ━━━━━━ declaration
  ╵
  src\app\core\sass\cecom-theme.scss 11:1  core()
  src\app\core\sass\cecom-theme.scss 11:1  root stylesheet

已尝试ng generate @angular/material:mdc-migration,但未检测到该文件存在任何问题。

ddrv8njm

ddrv8njm1#

材料芯在材料Angular 15中没有任何参数
只能这样称呼它@include mat.core();
在主题定义过程中,您需要将排版配置与主调色板和强调调色板沿着传递

$mat-typography: mat.define-typography-config(
 $headline-1:
    mat.define-typography-level(
      48px,
      112px,
      400,
      $font-family: "Roboto",
      $letter-spacing: -0.01em
    ),
    ***
    );

$light-theme: mat.define-light-theme(
  (
    color: (
      primary: $light-primary-palette,
      accent: $light-accent-palette,
      warm: $light-warn-palette,
    ),
    // Only include `typography` and `density` in the default dark theme.
    typography: $mat-typography,
    density: $mat-density, // new property for fields density
  )
);

相关问题