Vue CLI:怎樣創建包含 Vue Router 的項目
最近更新時間 2020-03-10 19:22:37
全局安裝 VUE
npm install -g @vue/cli
OR
yarn global add @vue/cli
安裝成功後可以使用 vue 命令查看版本號。
vue --version
@vue/cli 4.2.3
添加 Vue Router
第一種方法,初始化項目時選擇手動安裝:
vue create hello-world
Vue CLI v4.2.3 ? Please pick a preset: default (babel, eslint) ❯ Manually select features
第二種方法,在已有項目中添加 Vue Router:
vue add router
📦 Installing @vue/cli-plugin-router... yarn add v1.17.3 [1/4] 🔍 Resolving packages... info There appears to be trouble with your network connection. Retrying... [2/4] 🚚 Fetching packages... [3/4] 🔗 Linking dependencies... [4/4] 🔨 Building fresh packages... success Saved lockfile. success Saved 0 new dependencies. ✨ Done in 25.82s. ✔ Successfully installed plugin: @vue/cli-plugin-router ? Use history mode for router? (Requires proper server setup for index fallback in production) Yes 🚀 Invoking generator for @vue/cli-plugin-router... 📦 Installing additional dependencies... yarn install v1.17.3 [1/4] 🔍 Resolving packages... [2/4] 🚚 Fetching packages... [3/4] 🔗 Linking dependencies... [4/4] 🔨 Building fresh packages... success Saved lockfile. ✨ Done in 10.03s. ⚓ Running completion hooks... ✔ Successfully invoked generator for plugin: @vue/cli-plugin-router