NPM
在用 Vue.js 構建大型應用時推薦使用 NPM 安裝,NPM 能很好地和諸如 Webpack 或 Browserify 模塊打包器配合使用。Vue.js 也提供配套工具來開發單文件組件。
# 最新穩定版 $ npm install vue
|
命令行工具 (CLI)
Vue.js 提供一個官方命令行工具,可用於快速搭建大型單頁應用。該工具提供開箱即用的構建工具配置,帶來現代化的前端開發流程。只需幾分鐘即可創建並啓動一個帶熱重載、保存時靜態檢查以及可用於生產環境的構建配置的項目:
# 全局安裝 vue-cli $ npm install --global vue-cli # 創建一個基於 webpack 模板的新項目 $ vue init webpack my-project # 安裝依賴,走你 ? Project name (my-project) //請輸入項目名稱,回車默認
? Project description (A Vue.js project) //請輸入項目描述,回車默認
? Author xsl <[email protected]> //請輸入作者名,回車默認
? Vue build //請選擇構建模式,請直接回車選擇第一條
> Runtime + Compiler: recommended for most users
Runtime-only: about 6KB lighter min+gzip, but templates (or any Vue-specific
HTML) are ONLY allowed in .vue files - render functions are required elsewhere
? Install vue-router? Yes //是否安裝vue-router,回車
? Use ESLint to lint your code? Yes //是否安裝ESLint代碼檢查器,回車
//個人比較偏愛airbnb的編碼規範,此處選擇第二項
Standard (https://github.com/feross/standard)
>AirBNB (https://github.com/airbnb/javascript)
none (configure it yourself)
? Setup unit tests with Karma + Mocha? Yes //單元測試,請按需選擇
? Setup e2e tests with Nightwatch? Yes //端到端測試,請按需選擇
$ cd my-project $ npm install $ npm run dev 安裝完成!可以開搞了 |