建立一個基於webpack模板的新項目vue
D:\Git $ vue -V 2.9.6 D:\Git $ vue init webpack my-project ? Project name my-project ? Project description A Vue.js project ? Author hongda <hongda159505@qq.com> ? Vue build (Use arrow keys) ? Vue build standalone ? Install vue-router? Yes ? Use ESLint to lint your code? Yes ? Pick an ESLint preset Standard ? Set up unit tests Yes ? Pick a test runner jest ? Setup e2e tests with Nightwatch? Yes ? Should we run `npm install` for you after the project has been created? (recommended) npm vue-cli · Generated "my-project". # Installing project dependencies ... # ======================== npm WARN deprecated socks@1.1.10: If using 2.x branch, please upgrade to at least 2.1.6 to avoid a serious bug with socket data flow and an import issue introduced in 2.1.0 > chromedriver@2.38.3 install D:\Git\my-project\node_modules\chromedriver > node install.js Downloading https://chromedriver.storage.googleapis.com/2.38/chromedriver_win32.zip Saving to C:\Users\qhong\AppData\Local\Temp\chromedriver\chromedriver_win32.zip Received 782K... Received 1568K... Received 2352K... Received 3136K... Received 3299K total. Extracting zip contents Copying to target path D:\Git\my-project\node_modules\chromedriver\lib\chromedriver Done. ChromeDriver binary available at D:\Git\my-project\node_modules\chromedriver\lib\chromedriver\chromedriver.exe > uglifyjs-webpack-plugin@0.4.6 postinstall D:\Git\my-project\node_modules\webpack\node_modules\uglifyjs-webpack-plugin > node lib/post_install.js npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) added 1549 packages in 48.032s Running eslint --fix to comply with chosen preset rules... # ======================== > my-project@1.0.0 lint D:\Git\my-project > eslint --ext .js,.vue src test/unit test/e2e/specs "--fix" # Project initialization finished! # ======================== To get started: cd my-project npm run dev Documentation can be found at https://vuejs-templates.github.io/webpack
須要注意的是項目的名稱不能大寫,否則會報錯。node
Project name (my-project) # 項目名稱(個人項目)webpack
Project description (A Vue.js project) # 項目描述一個Vue.js 項目git
Author 做者(你的名字)github
Install vue-router? (Y/n) # 是否安裝Vue路由,也就是之後是spa(但頁面應用須要的模塊)web
Use ESLint to lint your code? (Y/n) # 使用 ESLint 到你的代碼? (Y [ yes ] / N [ no ])vue-router
Pick an ESLint preset (Use arrow keys) # 選擇一個預置ESLint(使用箭頭鍵)chrome
Setup unit tests with Karma + Mocha? (Y/n) # 設置單元測Karma + Mocha? (Y/ N)npm
Setup e2e tests with Nightwatch? (Y/n) # 設置端到端測試,Nightwatch? (Y/ N)json
固然這些都看你本身我的的狀況,我這裏是全選了是。
各目錄用途:
npm install
運行:
$ npm run dev > my-project@1.0.0 dev D:\Git\my-project > webpack-dev-server --inline --progress --config build/webpack.dev.conf.js 95% emitting DONE Compiled successfully in 4030ms 15:55:42 I Your application is running here: http://localhost:8080
提示已運行在8080端口
修改運行時自動打開瀏覽器:
目錄中config下的index.js修改,將autoOpenBrowser:false 改成true
意思是是否默認打開瀏覽器改成是。就行了