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