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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.