在我的角度项目中添加了角材料包之后,我使用了下面的代码来使用日期选择器。但是当我使用日期选择器代码时,任何HTML页面都会隐藏我的总页面。我是角度方面的新手,所以,我不熟悉这种角度行为。
account.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RegisterComponent } from './register/register.component';
import { LoginComponent } from './login/login.component';
import { AccountRoutingModule } from './account-routing.module';
import { ReactiveFormsModule } from '@angular/forms';
import { TestAccountComponent } from './test-account/test-account.component';
import { FogetPasswordComponent } from './foget-password/foget-password.component';
import { ResetPasswordComponent } from './reset-password/reset-password.component';
import { MatDatepickerModule } from '@angular/material/datepicker';
import {MatFormFieldModule} from '@angular/material/form-field';
@NgModule({
declarations: [
RegisterComponent,
LoginComponent,
TestAccountComponent,
FogetPasswordComponent,
ResetPasswordComponent
],
imports: [
CommonModule,
AccountRoutingModule,
ReactiveFormsModule,
MatDatepickerModule,
MatFormFieldModule
],
exports: [
ReactiveFormsModule
]
})
export class AccountModule { }component.html
<div><mat-form-field class="example-full-width" appearance="fill">
<mat-label>Choose a date</mat-label>
<input matInput [matDatepicker]="picker">
<mat-datepicker-toggle matSuffix [for]="picker">
<mat-icon matDatepickerToggleIcon>keyboard_arrow_down</mat-icon>
</mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>
</div>我是新来的。我不知道为什么这段代码会隐藏我的页面?
发布于 2021-06-12 13:29:41
你进口MatIconModule了吗?因为在mat窗体字段中使用mat图标。
如果不是
从“@角/材料/图标”导入{MatIconModule};
进口:.,MatIconModule
https://stackoverflow.com/questions/67936179
复制相似问题