I'm trying to create a route to add a locale prefix for all the routes, I got it working using this code:
routes: [{
path: '/:lang',
component: {
template: '<router-view />'
},
children: [
{
path: '',
name: 'home',
component: Home
},
{
path: 'about',
name: 'about',
component: About
},
{
path: 'contact',
name: 'contact',
component: Contact
}
]
}]
For the default locale en
I don't want to set this prefix so params.lang
is going to be the full path in this case and not the locale code, so requesting any path without a locale code will render the Home
component which matches.
So how can I do this? Does a navigation guard like beforeEnter
help in this case?