简体   繁体   English

如何在spa应用程序的asp.net core 2中生成组件? 像有角度的CLI

[英]How to generate component in asp.net core 2 in spa application? like angular CLI

  1. First installed angular cli globally: npm install @angular/cli@latest -g 首次在全球范围内安装angular cli:npm install @ angular / cli @ latest -g

  2. Then I create an angular project outside using by cli: ng new hello-world 然后,我使用cli在外部创建一个角度项目:ng new hello-world

  3. Copy .angular-cli.json file into the root my project: 将.angular-cli.json文件复制到我的项目的根目录中:

  4. Modify .angular-cli.json file: "root" : "src" change to "root" : "ClientApp" 修改.angular-cli.json文件:将“ root”:“ src”更改为“ root”:“ ClientApp”

  5. I Installed angularCli dev in my root project: cd MyProject 我在我的根项目中安装了angularCli dev:cd MyProject

  6. Then npm install @angular/cli@latest --save-dev 然后npm install @ angular / cli @ latest --save-dev

  7. I Went to that directory : cd ClientApp/app/components 我进入该目录:cd ClientApp / app / components

  8. Then I wrote : ng gc MyComponentName 然后我写了:ng gc MyComponentName

It shown me this screen: 它显示了此屏幕:

enter image description here ] 1 在此处输入图像描述 ] 1

Solved : 解决了 :

You need to rename the file app.module.shared.ts To app.module.ts under ClientApp/app and correct the file paths in app.module.browser.ts and app.module.server.ts accordingly. 您需要将文件app.module.shared.ts重命名为ClientApp / app下的app.module.ts ,并相应地更正app.module.browser.tsapp.module.server.ts的文件路径。

Tested under : 经过测试:
Environment : Development 环境:发展
Target Framework : netcoreapp2.0 目标框架:netcoreapp2.0
SPA template : angular SPA模板:角形

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM