我正在尝试使用Angular Material的输入字段,但显示不正确。这是我的代码:
app.component.html:
<div>
<mat-form-field appearance="fill">
<mat-label>Input</mat-label>
<input matInput>
</mat-form-field>
<router-outlet></router-outlet>
</div>
app.module.ts:
import { MatInputModule } from '@angular/material/input';
import { MatFormFieldModule } from '@angular/material/form-field';
imports: [
BrowserModule,
AppRoutingModule,
MatInputModule,
MatFormFieldModule,
BrowserAnimationsModule
]
我得到的只是一个白屏,直到我尝试聚焦该领域:
Angular CLI: 9.1.1
Node: 12.16.1
OS: linux x64
Angular: 9.1.2
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.901.1
@angular-devkit/build-angular 0.901.1
@angular-devkit/build-optimizer 0.901.1
@angular-devkit/build-webpack 0.901.1
@angular-devkit/core 9.1.1
@angular-devkit/schematics 9.1.1
@angular/cdk 9.2.1
@angular/cli 9.1.1
@angular/material 9.2.1
@ngtools/webpack 9.1.1
@schematics/angular 9.1.1
@schematics/update 0.901.1
rxjs 6.5.5
typescript 3.8.3
webpack 4.42.0
答案 0 :(得分:0)
此问题得以解决,因为我使用的是purple-green
主题,该主题在黑暗中是亮的,而我忘记了将mat-app-background
类应用于body
。