【发布时间】:2018-06-01 01:42:41
【问题描述】:
我的 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"):
问题:
Material Label 在 MatFormFieldModule Here's the link 下
现在,Angular Material 不知道 Mat-Label 问题的可能原因是什么。
这里是 HTML
<mat-form-field> <mat-label>Both a label and a placeholder</mat-label> <input matInput placeholder="Simple placeholder"> </mat-form-field>
【问题讨论】:
-
您是否检查过您的应用设置以及是否将
CUSTOM_ELEMENTS_SCHEMA导入app.module.ts?这应该可以解决问题并消除错误。import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';然后schemas: [ CUSTOM_ELEMENTS_SCHEMA ],在 @NgModule({...., schemas: [ CUSTOM_ELEMENTS_SCHEMA ]}) -
@k.vincent,这行得通,但它不应该要求这样做。更新 Angular 是一整天的工作 :( 伙计们,你可以做得更好
-
感谢@k.vincent 解决了我的问题
-
@CHAHISaad,很高兴它有帮助!
标签: angular typescript angular-material