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

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

作者: hwl0123 | 来源:发表于2019-02-14 15:53 被阅读0次
    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{}
    

    相关文章

      网友评论

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

          本文链接:https://www.haomeiwen.com/subject/tzxjdqtx.html