我有以下目录结构
我想创建一个新页面,比如说一个关于页面。
我想把它放在 src/app/page/about/*
所以我尝试:
ng generate component pages/about
但我收到此错误:
Error: More than one module matches. Use skip-import option to skip importing the component into the closest module.
More than one module matches. Use skip-import option to skip importing the component into the closest module.
使用页面来存储我的单独页面是个好主意吗?
如何使用 angular-cli 在子目录中生成组件?
最佳答案
因为有 2 个模块(app.module.ts
,shared.module.ts
)发现 CLI 不知道在哪个模块中声明您的组件。要解决这个问题,您必须使用 module
选项告诉 CLI 您希望在哪个模块中声明您的组件
ng generate component pages/about --module=app.module
// or
ng generate component pages/about --module=shared.module
关于angular-cli - ng 在子目录中生成组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48102863/