angular環境搭建
阿新 • • 發佈:2017-07-04
查看版本 index 都是 元素 ons plain 搭建 令行 模板
一、環境搭建
1、安裝nodeJS (安裝完成之後 npm -v 查看版本)
2、安裝angular的命令行工具
sudo npm install -g @angular/cli
3、安裝webstorm
4、使用 ng -v 查看angular命令行的安裝結果
5、創建項目 ng new auction (auction為項目的名稱)
6、在項目中引入bootstrap和jQuery
npm install bootstrap --save
npm install jquery --save
7、在.angular-cli.json文件,把bootstrap和jQuery添加進去:
因為angular用的是微軟開發的typescript語言,我們需要在終端做下面的操作,以便讓typescript認識bootstrap和jQuery一些字符(比如jQuery的$):
npm install @types/bootstrap --save-dev
npm install @types/jquery --save-dev
8、為項目添加組件
ng g component navbar
9、項目啟動
ng serve或者npm start
默認端口都是4200:http://localhost:4200
修改默認端口 ng serve -p 3000
10、項目的打包
ng build
二、淘寶鏡像安裝(把npm的指令改為cnpm就可以)
npm
install
-g cnpm --registry=https:
//registry
.npm.taobao.org
二、angular必備元素
@component裝飾器、模板 template、控制器controller
angular環境搭建