Dynamic redirecting

This is the ultimate redirect. You can access the route the user is trying to access and decide where you want to redirect him (you can't cancel the redirection though):

...{ path: '/air', component: Air },{ path: '/bags', name: 'bags', component: Bags },{ path: '/super-shirt/:size', component: SuperShirt },{ path: '/shirt/:size?', component: Shirt},{ path: '/shirts/:size?',  redirect: to => {    const { hash, params, query } = to    if (query.colour === 'transparent') {      return { path: '/air', query: null }    }    if (hash === '#prada') {      return { name: 'bags', hash: '' }    }    if (params.size > 10) {      return '/super-shirt/:size'    } else {      return '/shirt/:size?'    }  }}

Get Vue.js 2 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.