Now we need to make the routes available in the application. To do so, first, we need to declare the routes and the components that the routes will render. Follow these steps to create your Vue application router correctly:
- In the src/router folder, open the index.js file.
- Import the Contact component page:
import Vue from 'vue';
import VueRouter from 'vue-router';
import Home from '../views/Home.vue';
import Contact from '../views/contact.vue';
- In the routes array, we need to create a new route object. This object will have the path property defined as '/contact', name defined as 'contact', and component pointing to the imported Contact component:
{
path: '/contact',
name: 'contact',
component: Contact,
},
To run the server and see your component, you need to open Terminal (macOS or Linux) or Command Prompt/PowerShell (Windows) and execute the following command:
> npm run serve
Here...