读起来真费劲。一会儿 test01 一会儿 temp01 一会儿又 test02.
你把 NgModule 想象成一个高层次的容器,它比 js 的 module 高一个维度,但是概念类似。里面有的 component 你要声明它在里面,里面用到了其他的 module 里的 component 你要 import 那个 module,如果你想让内部声明的组件可以供别人 import 来使用你就需要 export。当然 provider 是另外一回事,涉及 injector。
第一,temp01 既然是定义在公共模块 publicModule
里的,那么有没有在 declarations 字段声明这个组件呢?
第二,你希望别人导入 publicModule
就可以使用 temp01,那有没有在 exports 字段声明这个组件呢?
第三,test02
是什么?全文没有提及突然发问。
第四,Test01Component
既然是子模块的子路由在使用,为什么要在 AppModule
的 declarations 字段声明?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…