Could not find an NgModule. Use the skip-import option to skip importing in

139 阅读1分钟

该错误消息意思是创建Component时未指定其属于哪一个module,因此先用命令行ng g m parent创建一个名为parent的module:

默认生成的代码如下图所示:

然后使用ng g c 创建一个名为parent-child的Component,使用参数 -m parent挂接到刚才新建的名为parent的module即可。

更多Jerry的原创文章,尽在:“汪子熙”: