[英]'md-card' is not a known element in material 2
我使用角度4和材质2处理Web应用程序。我收到此错误
parse errors:
'md-card' is not a known element:
1. If 'md-card' is an Angular component, then verify that it is part of this module.
2. If 'md-card' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("<h2>Nothing to show</h2>
[ERROR ->]<md-card>Simple card</md-card>
"): ng:///AppAccessModule/SPLoginComponent.html@1:0
at syntaxError
当我尝试在一个文件夹内嵌套两次的组件中使用材料时
这些是我的结构:
-----Components(folder)
-------Auth(folder)
--------Login(component1)
--------Signup(component2)
但如果我下一次喜欢这样:
-------Auth(folder)
--------Login(component 1)
--------Signup(component2)
我没有任何问题我该怎么做才能解决这个问题? 谢谢
在你的src/app/modules/app-access.module.ts
导入MdCardModule
:
import { MdCardModule } from '@angular/material';
并在导入中添加:
imports: [
....
MdCardModule,
],
如果您使用材料2中的任何其他组件,也请添加它们。
import { MatCardModule } from '@angular/material/card';
@NgModule({ ..
imports: [..
MatCardModule]
您正在导入在Beta-3中弃用的MaterialModule
。 导入要单独使用的所有Material模块,即MdCardModule
或创建自己的BoomMaterialModule
,您可以导入和导出要在应用程序中使用的所有Material模块。
错误:
import { MaterialModule,MdSelectModule } from '@angular/material';
^^^^^^^^^^^^^^
要么导入MdCardModule
或创建BoomMaterialModule:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import {
MdButtonModule,
MdButtonToggleModule,
MdCardModule,
...
MdExpansionModule
} from '@angular/material';
import 'hammerjs';
@NgModule({
imports: [
CommonModule,
MdButtonModule,
MdButtonToggleModule,
MdCardModule,
...
MdExpansionModule
],
exports: [
MdButtonModule,
MdButtonToggleModule,
MdCardModule,
...
MdExpansionModule
]
})
export class BoomMaterialModule {
}
如果您有shared.module.ts或者您只是单独导入模块,请确保在Angular的BrowserModule之后导入Angular Material模块,因为导入顺序对NgModules很重要
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.