O'Reilly logo

The Majesty of Vue.js by Kostas Maniatis, Alex Kyriakidis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Route matching

While the options we reviewed for routing, serve our needs in a small project like our example, presumably you will need more options as your project grows. For instance, if we decide later to change /login URL to /signin, we will have to update all the links directing to the login page. To prevent this from happening, we can give each route a name.

Named routes

To name a route we have to update the route configuration file.

src/main.js:

router.map({ '/': { name: 'home', // give the route a name component: require('./components/Hello.vue') }, '/login': { name: 'login', // give the route a name component: require('./components/Login.vue') }, '/stories': { name: 'stories', component: require('./components/Stories.vue'), subRoutes: { ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required