Introducing Vue-Router and Loading URL-Based Components Chapter 8
Instead, you can add a route and specify the redirect within that:
const router = new VueRouter({
routes: [
{
path: '/',
component: Home
},
{
path: '/about',
redirect: '/about-us'
},
{
path: '/about-us',
component: About
},
{
path: '*',
component: PageNotFound
}
],
linkActiveClass: 'active',
linkExactActiveClass: 'current'
});
Once again, the contents of the redirect key can be a literal string or an object—much like
the push() function. With the preceding, if the user visits /about, they will instantly be
redirected to /about-us and the About component shown.
Alias routes
There may be circumstances where you want to show the same component under two
URLs. Although not recommended as standard practice, there are some edge cases where
this is required.