Angular CLI脚手架的搭建

版权声明:前端菜鸟--人间草木所有 https://blog.csdn.net/qq_43258252/article/details/88575727

*****先要安装node.js,使用npm包管理工具 node.js安装方法如下*****

https://blog.csdn.net/shiyaru1314/article/details/54963027

https://blog.csdn.net/qq_42564846/article/details/82688266

大家都知道国内直接使用 npm 的官方镜像是非常慢的,这里推荐使用淘宝 NPM 镜像。

淘宝 NPM 镜像是一个完整 npmjs.org 镜像,你可以用此代替官方版本(只读),同步频率目前为 10分钟 一次以保证尽量与官方服务同步。

你可以使用淘宝定制的 cnpm (gzip 压缩支持) 命令行工具代替默认的 npm:

npm install -g cnpm --registry=https://registry.npm.taobao.org

 

安装 Angular CLI 脚手架

npm install -g @angular/cli

使用 Angular CLI 脚手架生成项目

Angular CLI 为我们提供了两种方式,用于创建新的应用程序:

  • ng init - 在当前目录创建新的应用程序
  • ng new - 创建新的目录,然后在新建的目录中运行 ng init 命令

因此 ng new 与 ng init 的功能是相似的,只是 ng new 会为我们创建新的目录。

假设你还未创建新的目录,那么我们需要使用 ng new 命令来创建新的项目:

ng new my-app

然后会问你两个问题,如下:

 

 

启动项目

安装完成后,进入my-app文件夹下

cd my-app

然后启动项目

ng serve

angular-cli的默认项目地址是 http://localhost:4200/

在浏览器输入它,即可启动项目

猜你喜欢

转载自blog.csdn.net/qq_43258252/article/details/88575727