【发布时间】:2018-02-20 16:09:50
【问题描述】:
错误
Uncaught Error: Template parse errors:
'md-form-field' is not a known element:
1. If 'md-form-field' is an Angular component, then verify that it is part
of this module.
2. If 'md-form-field' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA'
to the '@NgModule.schemas' of this component to suppress this message. ("
我已经用角度材料实现了角度输入
网址https://material.angular.io/components/input/overview
html
<form class="example-form">
<md-form-field class="example-full-width">
<input mdInput placeholder="Favorite food" value="Sushi">
</md-form-field>
</form>
谷歌搜索后我找到了链接
上面写着
import { MdFormFieldModule } from '@angular/material';
@NgModule({
imports: [
....
MdFormFieldModule,
....
]
app.module.ts 导入后
从'@angular/material'导入{ MdFormFieldModule };
ERROR in D:/frontend/src/app/app.module.ts (97,10): Module '"D:/frontendapp/node_modules/@angular/material/material"' has no exported member 'MdFormFieldModule'.
- 谁能建议我缺少什么。
【问题讨论】:
-
确保您的
@angular/material版本是2.0.0-beta.10 并且没有MdFormFieldModule,只需导入MdInputModule并将其添加到导入数组中。 -
@Pengyy
MdFormFieldModule是在 beta.10 中引入的,它必须与MdInputModule一起在模块导入中导入
标签: javascript angular angular-material