In Vue, you must explicitly install Vue Router to create routes in a traditional Vue app. Even if you are using Vue CLI (which we will cover in Chapter 11, Writing Route Middlewares and Server Middlewares), you must select Manually select features to pick Router from the options that you are prompted to select, to choose the features you need. So, let's take a look at how you can install it manually in this section. There are two options to install Vue Router:
- You can use npm:
$ npm install vue-router
Then, in the app root, explicitly import vue-router via Vue.use():
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
- Alternatively, you can use CDN or direct download:
<script src="/path/to/vue.js"></script>
<script src="/path/to/vue-router.js"></script>
If you are using CDN, simply add vue-router after the Vue core and the rest of the installation will be taken care of by...