2019-01-14 一个组件在两个模块中使用,导致报错

2019-02-14  本文已影响0人  hwl0123
image.png
Error: Type Modders is part of the declarations of 2 modules: BackAppModule and TskAppModule! 
Please consider moving Modders to a higher module that imports BackAppModule and TskAppModule. 
You can also create a new NgModule that exports and includes Modders then import that NgModule in BackAppModule and TskAppModule.

一个组件在两个模块中使用,导致报错。
将该组件定义到独立模块,在其他模块中引用该模块。

// 定义一个独立模块
import {NgModule}      from '@angular/core';
import {CommonModule} from '@angular/common';
import {InfoComponent} from "../info/info.component";
@NgModule({
  imports: [CommonModule],
  exports:      [ InfoComponent ],
  declarations: [InfoComponent]
})
export class InfoModule {}

// 引入到两个模块中
import { InfoModule } from '../common/tsk.common.module';
@NgModule({
    imports:[InfoModule ],
    declarations:[
        FnshListCmpt
    ]})
export class FnshAppModule{}
上一篇下一篇

猜你喜欢

热点阅读