代码之家  ›  专栏  ›  技术社区  ›  Sandra Willford

多个模块匹配。使用skip import选项跳过将组件导入最近的模块

  •  0
  • Sandra Willford  · 技术社区  · 6 年前

    在以前的版本中,我刚刚能够生成这样一个新组件。。。

    ng g c modules/update-tables/containers/users-container
    

    然后我试着。。。

    ng g c containers/users-container --module=update-tables
    

    错误:指定的模块不存在

    然后我试着。。。

    ng g c containers/users-container --module UpdateTablesModule
    

    enter image description here

    2 回复  |  直到 6 年前
        1
  •  1
  •   Martin Adámek    6 年前

    *.module.ts 文件来自 /app

    ng g c containers/users-container ./modules/update-tables/update-tables/update-tables.module.ts
    

    .module.ts 后缀:

    ng g c containers/users-container ./modules/update-tables/update-tables/update-tables
    

    它甚至可以在没有模块名的情况下工作,然后它将使用给定文件夹中的第一个模块名,因此最好指定它:

    ng g c containers/users-container ./modules/update-tables/update-tables
    
        2
  •  0
  •   mohsenmadi    6 年前

    我以前看过这个问题。没有什么能阻止您自己创建模块。我查看任何一个现有的模式,例如including@NgModule和all。对于该文件,创建一个名为users的文件-容器.module.ts。然后将其添加到应用模块ts(或任何你需要包含它的模块)你自己。