步驟 1. 設置開發環境
安裝命令:npm install -g @angular/cli
安裝後出現下圖狀況:html
![](http://static.javashuo.com/static/loading.gif)
則繼續執行:
清空緩存: npm uninstall -g angular-cli
清空緩存後繼續執行直至成功:npm install -g @angular/cli
測試是否安裝成功:
命令行輸入 : ng -v
出現下圖則證實安裝成功
步驟 2. 建立新項目
生成新項目命令:ng new my-app
安裝成功後以下圖所示:(問題)npm
![](http://static.javashuo.com/static/loading.gif)
http://www.ngui.cc/news/show-2039.html瀏覽器
解決辦法:npm cache clean --force緩存
安裝成功如圖示:服務器
![](http://static.javashuo.com/static/loading.gif)
步驟 3. 啓動開發服務器
進入項目目錄,並啓動服務器,命令以下:
cd my-app ng serve --open
以下圖:
![](http://static.javashuo.com/static/loading.gif)
步驟 4.在如下目錄中找到新建的項目並打開測試
![](http://static.javashuo.com/static/loading.gif)
步驟 5. 編輯Angular 組件ui
![](http://static.javashuo.com/static/loading.gif)
修改後瀏覽器自動刷新spa
![](http://static.javashuo.com/static/loading.gif)