Angular--命令集

image.png

通过命令行创建组件,路由等,以下内容均采集于网络,此处只是做一个记录,喜欢的可以收藏
npm install -g @angular/cli 安装angular cli脚手架
npm install -g cnpm 安装淘宝镜像
npm uninstall -g @angular/cli 卸载angular cli
npm cache clean 清除缓存
cnpm install -g @angular/cli npm 淘宝镜像方式重新安装
ng -v 查看版本/检验是否安装成功
ng new progect 创建新项目
进入项目目录
cnpm install / npm install 安装依赖
ng serve --open 启动项目
ng serve --port 1234 更改默认端口号
ng serve --host 192.168.1.1 将服务发到局域网中
ng generate component example 生成组件带有模版
ng generate component example -it 生成内联模版(不会单独生成html文件)
ng generate directive my-directive - 生成一个新指令
ng generate pipe my-pipe - 生成一个新管道
ng generate service my-service - 生成一个新服务
ng generate route my-route - 生成一个新路由
ng generate class my-class - 生成一个简易的模型类
简写
ng g cl my-new-class 新建 class
ng g c my-new-component 新建组件
ng g d my-new-directive 新建指令
ng g e my-new-enum 新建枚举
ng g m my-new-module 新建模块
ng g p my-new-pipe 新建管道
ng g s my-new-service 新建服务
以下可能常用的命令参数有:
–flat 表示是否不需要创建文件夹
–inline-template (-it) 模板是否应该放在ts文件里
–inline-style (-is) 样式是否应该放在ts文件里.
–spec 是否需要创建spec文件(测试文件)
–view-encapsulation (-ve) View Encapsulation策略 (简单理解为样式文件的作用范围策略).
–change-detection (-cd) 变化检查策略.
–prefix 设定这个component的前缀
–dry-run (-d), 打印出生成的文件列表, 而不直接生成.
————————————————
版权声明:本文为CSDN博主「畦步千里」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/a1192492677/article/details/101430048

你可能感兴趣的:(Angular--命令集)