Vue腳手架創建項目


創建一個基於webpack模板的新項目

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

需要注意的是項目的名稱不能大寫,不然會報錯。

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)

當然這些都看你自己個人的情況,我這里是全選了是。

各目錄用途:

安裝項目所需要的依賴

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 

意思是是否默認打開瀏覽器改為是。就好了

 

 

 

 

https://segmentfault.com/a/1190000011275993

https://www.jianshu.com/p/1626b8643676


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM