当前输入字段如下:
我的一个组件具有以下HTML:
<form class="example-form">
<mat-form-field class="example-full-width">
<input matInput placeholder="Favorite food" value="Sushi">
</mat-form-field>
<mat-form-field class="example-full-width">
<textarea matInput placeholder="Leave a comment"></textarea>
</mat-form-field>
</form>
我的app.module.ts具有以下问题:
为什么输入的样式不像examples那样?
答案 0 :(得分:1)
尝试在NgModule中导入“物料表单字段模块”。
另外,还需要在style.scss
@import '~@angular/material/prebuilt-themes/deeppurple-amber.css';
然后在app.module.ts
中添加MatInputModule
import {MatInputModule,MatFormFieldModule} from '@angular/material';
// ....
imports: [
MatFormFieldModule,
MatInputModule,
...
],
请参阅文档:Form-Field和Example