mat-button is not a known element
我不明白。我想我已经导入了所有必需的模块,但是它一直告诉我:
1 | 'mat-button' is not a known element: |
app.module.ts:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { MatButtonModule } from '@angular/material/button'; import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { AppComponent } from './app.component'; @NgModule({ imports: [ BrowserModule, FormsModule, BrowserAnimationsModule, MatButtonModule, ], declarations: [AppComponent], providers: [], bootstrap: [AppComponent], }) export class AppModule {} |
app.component.ts:
1 2 3 4 5 6 7 8 9 10 | import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: 'app.component.html', styleUrls: ['app.component.scss'], }) export class AppComponent { constructor() {} } |
app.component.html
1 | <mat-button>foo</mat-button> |
app.component.scss为空。
我知道有很多与此相关的帖子。但是没有任何帮助,因为我认为我正确地导入了所有内容(
是:
1 | <button mat-button>foo</button> |
不是
1 | <mat-button>foo</mat-button> |
官方文件。