Ran*_*z67 13 angular-material angular
我的Angular材料中出现错误:
compiler.js:466 Uncaught Error: Template parse errors:
'mat-label' is not a known element:
1. If 'mat-label' is an Angular component, then verify that it is part of this module.
2. If 'mat-label' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
</mat-form-field>
<mat-form-field>
[ERROR ->]<mat-label>Both a label and a placeholder</mat-label>
<input matInput placeholder="Simple"):
Run Code Online (Sandbox Code Playgroud)
题:
材料标签位于MatFormFieldModule 下面是链接
现在,问题的可能原因是什么,为什么Mat-Label不为Angular Material所知.
这是HTML
Run Code Online (Sandbox Code Playgroud)<mat-form-field> <mat-label>Both a label and a placeholder</mat-label> <input matInput placeholder="Simple placeholder"> </mat-form-field>
Sim*_*ver 12
如果您有多个模块,请确保要MatFormFieldModule在每个模块中导入。仅将其导入到根模块中是不够的。
例如,我有一个CommonWidgetsModule,其中包含一些常见的小部件(我自己的),但是我只将其导入MatFormFieldModule到app.module.ts文件中。
// common-widgets.module.ts
@NgModule({
imports: [
CommonModule,
SharedModule,
RouterModule,
MatIconModule,
MatFormFieldModule,
MatInputModule
],
declarations: DECLARATIONS,
exports: DECLARATIONS
})
export class CommonWidgetsModule { }
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
25668 次 |
| 最近记录: |