I have this little router over here, and basically I want to have a default language for my site. This means that the same content should be seen if you access www.example.com/about and www.example.com/es/about
I thought an alias would be apropiate for this, however I'm getting a error when tryin to access /about.
[vue-router] missing param for aliased route with path "/:language/about": Expected "language" to be defined
This makes sense as the :language param is not set, is there any way I can implement what I want? Can I set a fixed :language param whenever the user hits the alias?
This is my router.
router = new Router({
routes: [
{
path: '/:language/about',
alias: '/about'
component: About
}
]
})
Using optional parameters (append ?) will solve this. You won't even need the alias:
router = new Router({
routes: [
{
path: '/:language?/about',
component: About
}
]
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With