Uncaught Error: Type **Component is part of the declarations of 2 modules Please consider moving **Component to a higher module that imports **Module and **Module. You can also create a new NgModule that exports and includes **Component then import that NgModule in **Module and **Module.
问题分析
一个组件在两个模块中定义,导致报错。
解决方案
将该组件定义到模块中,在其他模块中引用该模块。
如以下,将InfoComponent定义到InfoModule模块中:
import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {InfoComponent} from "../info/info.component";
@NgModule({
imports: [BrowserModule
],
exports: [ InfoComponent ],
declarations: [InfoComponent]
})
export class InfoModule {
}
再将该模块引用到其他模块的imports数组中。
angular、spring cloud 开源实战项目源码:https://gitee.com/xfdm/FCat
QQ群:549141844代码持续更新…