Creating routes
The most basic configuration for Vue Router is to provide a routes array, which maps URLs to the corresponding page components. This array will contain objects with at least two properties: path and component.
Note
Note that by page components I'm simply referring to any components that we've designated to represent a page in our app. They are regular components in every other way.
For now, we're only going to have two routes in our app, one for our home page and one for our listing page. The HomePage component doesn't exist yet, so we'll keep its route commented out until we create it.
resources/assets/js/router.js:
import ListingPage from '../components/ListingPage.vue';
export default new VueRouter({
mode: 'history',
routes: [
// { path: '/', component: HomePage }, // doesn't exist yet!
{ path: '/listing/:listing', component: ListingPage }
]
});You'll notice that the path for our ListingPage component contains a dynamic segment :listing so that this route will...