1.vue安裝:vue
$ cnpm install vue
2.安裝vue-cli腳手架構建工具:webpack
# 全局安裝 vue-cli $ cnpm install --global vue-cli
3.構建於webpack模板的一個新項目:web
#my-project爲自定義項目名 $ vue init webpack my-project 初始化一個項目,或使用 $ vue init webpack-simple my-project
4.initvue-router
Project name (my-project) # 項目名稱(個人項目) Project description (A Vue.js project) # 項目描述一個Vue.js 項目 Author 做者(你的名字) Install vue-router? (Y/n) # 是否安裝Vue路由,也就是之後是spa(但頁面應用須要的模塊) Use ESLint to lint your code? (Y/n) # 使用 ESLint 到你的代碼? (Y [ yes ] / N [ no ]) Pick an ESLint preset (Use arrow keys) # 選擇一個預置ESLint(使用箭頭鍵) Setup unit tests with Karma + Mocha? (Y/n) # 設置單元測Karma + Mocha? (Y/ N) Setup e2e tests with Nightwatch? (Y/n) # 設置端到端測試,Nightwatch? (Y/ N)
? Project name vue-demovue-cli
? Project description demonpm
? Author luoxiaowei <luoxiaowei@100tal.com>架構
? Vue build standalone工具
? Install vue-router? Yes測試
? Use ESLint to lint your code? Yesui
? Pick an ESLint preset none
? Set up unit tests No
? Setup e2e tests with Nightwatch? No
? Should we run `npm install` for you after the project has been created? (recom
mended) npm
cd vue-demo
cnpm run dev