創(chuàng)建 vue 項(xiàng)目
創(chuàng)建一個(gè)新項(xiàng)目莹菱,運(yùn)行:
vue create hello-world
警告
如果你在 windows 系統(tǒng)中通過 minTTY 使用 Git Bash梭依,這個(gè)交互彈窗不會(huì)有效果召庞。你必須使用 winpty vue.cmd create hello-world 來運(yùn)行命令俩檬。如果你仍然想使用 vue create hello-world 語法柒莉,你可以通過在你的 ~/.bashrc 文件中添加增加一行內(nèi)容來設(shè)置命令的別名:alias vue='winpty vue.cmd'盼砍。設(shè)置后你將需要重啟你的 Git Bash 終端會(huì)話來更新 bashrc 文件尘吗。
你將被提示需要進(jìn)行預(yù)設(shè)。你可以選擇一個(gè)有 Babel+ESLint 的默認(rèn)預(yù)設(shè)浇坐,或者通過選擇“Manuall select features”來選擇你需要的功能
如果你手動(dòng)選擇功能細(xì)節(jié)擒贸,在彈窗的底部你也有保存你的選項(xiàng)作為預(yù)設(shè)的選項(xiàng)臀晃,這樣你之后就可以重復(fù)使用。下一節(jié)我們將討論預(yù)設(shè)和插件介劫。
~/.vuerc
保存的預(yù)設(shè)被存儲(chǔ)在你的用戶 home 目錄里面一個(gè)名為 .vuerc 的 json 文件中徽惋。如果你想修改保存的預(yù)設(shè)/選項(xiàng),可以修改該文件座韵。
在項(xiàng)目創(chuàng)建過程中险绘,你也許被彈窗提示選擇一個(gè)更好的包管理工具,或者使用淘寶的 npm 注冊(cè)鏡像進(jìn)行更快的依賴安裝回右。你的選擇也將被保存到 ~/.vuerc
vue create 命令也有一系列選項(xiàng)隆圆,你可以通過運(yùn)行以下命令來摸索:
vue create --help
Usage: create [options] <app-name>
create a new project powered by vue-cli-service
Options:
-p, --preset <presetName> Skip prompts and use saved or remote preset
-d, --default Skip prompts and use default preset
-i, --inlinePreset <json> Skip prompts and use inline JSON string as preset
-m, --packageManager <command> Use specified npm client when installing dependencies
-r, --registry <url> Use specified npm registry when installing dependencies
-g, --git [message|false] Force / skip git initialization, optionally specify initial commit message
-n, --no-git Skip git initialization
-f, --force Overwrite target directory if it exists
-c, --clone Use git clone when fetching remote preset
-x, --proxy Use specified proxy when creating project
-b, --bare Scaffold project without beginner instructions
-h, --help Output usage information