- 安裝 vue-cli
執(zhí)行指令npm i vue-cli -g
全局安裝
可以使用vue-V
查看版本號(hào)
2.初始化項(xiàng)目
執(zhí)行指令vue init webpack 項(xiàng)目名稱
可能會(huì)提示
Command vue init requires a global addon to be installed.
Please run npm install -g @vue/cli-init and try again.
不用擔(dān)心 按照他提示的 運(yùn)行
npm install -g @vue/cli-init
然后就可以愉快的 vue init webpack 項(xiàng)目名
了
? Project name haomeili
//你的項(xiàng)目名稱
? Project description A Vue.js project
//項(xiàng)目描述 一個(gè)vue.js項(xiàng)目
? Author wyy1208 <moanshangyin@163.com>
//作者 因?yàn)橹霸O(shè)置過git 所以就默認(rèn)我設(shè)置的git username和email
? Vue build standalone
這里會(huì)出現(xiàn)
- 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
這里選擇Runtime + Compiler: recommended for most users显拳;
? Install vue-router? Yes
//需要安裝vue路由嗎 根據(jù)需求
? Use ESLint to lint your code? Yes
//需要eslint檢查代碼規(guī)范嗎 看需求
? Pick an ESLint preset Standard
- Standard (https://github.com/feross/standard)
- Airbnb (https://github.com/airbnb/javascript) none (configure it yourself)
這里選擇Standard
? Set up unit tests No
//是否需要測(cè)試 根據(jù)需求
? Setup e2e tests with Nightwatch? No
//是否需要測(cè)試 根據(jù)需求
? Should we run `npm install` for you after the project has been created? (recommended) npm
//是否選擇npm 作為依賴包的安裝途徑
vue-cli · Generated "haomeili".
//提示創(chuàng)建成功
# Installing project dependencies ...
然后一串安裝
后來(lái)會(huì)提示
To get started:
cd haomeili
npm run dev
Documentation can be found at https://vuejs-templates.github.io/webpack
然后就可以愉快的cd到項(xiàng)目目錄 然后跑項(xiàng)目啦
先寫到這里 需要的再補(bǔ)充