【问题标题】:Circular Dependency issue component level in angular 12角度 12 中的循环依赖问题组件级别
【发布时间】:2022-06-14 16:05:33
【问题描述】:

我有一个 ParentComponent,它有一个子 ChildComponent,而 child 里面有 ParentComponent,所以这里有一个循环。 这是我面临的错误:

✖ Compiling with Angular sources in Ivy partial compilation mode. ERROR: projects/api/src/lib/api.component.ts:3:1 error NG3003: One or more import cycles would need to be created to compile this component, which is not supported by the current compiler configuration.

模板中使用了组件“ParentComponent”,但正在导入 它会创建一个循环: /lib/child/child.component.ts -> /lib/parent/parent.component.ts -> /lib/child/child.component.ts

在库的 tsconfig.base.json 文件中设置 "compilationMode": "partial" 会消除此错误,但在这种情况下,我们会失去向后兼容性!

【问题讨论】:

  • 在这种情况下,您必须避免无限嵌套的组件带有标志以使其停止在某处。

标签: angular angular12


猜你喜欢
  • 2019-07-30
  • 2020-03-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多