Using Vue Router to move around
In this section, we will look at Vue Router and learn how to use it. Vue Router helps in structuring the frontend code when designing a single-page application (SPA). An SPA is a web application that is presented to the user as a single HTML page, which makes it more responsive as the content inside the HTML page is updated without refreshing the page. The SPA requires the use of a router that will route to the different endpoints when updating data from the backend.
Using a router allows easier mapping between the URL path and components simulating page navigation. There are two types of routes that can be configured using Vue Router – dynamic and static routes. Dynamic routes are used when the URL path is dynamic based on some kind of data. For example, in /users/:id
, id
in the path will be populated with a value, which will be something such as /users/johnny
or users/acme
. Static routes are routes that do not contain any dynamic data, for...