【发布时间】:2023-01-10 12:26:04
【问题描述】:
我正在尝试使用材料角度的复选框,但它不起作用。我将逐步展示我在做什么:
**package.json**
"dependencies": {
"@angular/material": "^10.2.5",
}
**app.module.ts**
import { MatSliderModule } from '@angular/material/slider';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'
import { BrowserModule, Title } from '@angular/platform-browser'
@NgModule({
imports: [
MatCheckboxModule,
MatSliderModule,
BrowserModule,
BrowserAnimationsModule,
],
declarations: [AppComponent],
})
**app.component.html**
<mat-slider min="1" max="100" step="1" value="50"></mat-slider>
<mat-checkbox></mat-checkbox>
垫滑块工作正常,我也试过垫卡它工作正常,但与垫复选框我收到此错误:
'mat-checkbox' is not a known element:
1. If 'mat-checkbox' is an Angular component, then verify that it is part of this module.
2. If 'mat-checkbox' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.ng
我做错了什么?
【问题讨论】: