我无法在我的网络应用程序上使用此功能,因此我从 cli 创建了一个新项目(Angular 15),并使用“ng add @angular/material”添加了材料。
我将 app.component.html 编辑为简单的
<div>
<h1>This is an h1.</h1>
<h2>This is an h2.</h2>
</div>
现在是好东西。我的 styles.scss 是
@use '@angular/material' as mat;
@include mat.core();
$my-typography: mat.define-typography-config();
@include mat.typography-hierarchy($my-typography);
$my-custom-typography-config: mat.define-typography-config(
$headline-1: mat.define-typography-level(112px, 112px, 300, $letter-spacing: -0.05em),
);
@include mat.typography-hierarchy($my-custom-typography-config);
为了让这个应用程序读取我尝试设置的值,我缺少什么? 我尝试将其设置为我的真实应用程序中主题的一部分,但我也无法让这些排版设置在那里工作。
确保您已将课程添加到您的
index.html
。验证 <body>
标签是否包含 class="mat-typography"
。如果缺少,请像这样添加:
<body class="mat-typography">