Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vue-router update routes programmatically

Is there any way to update Vue-router routes programmatically without reloading the page?

I'm loading different route paths based on the language that is selected, e.g.:

{ path: '/' + i18n.t('url_welcome'), name: 'welcome, component: Welcome },

Unfortunately, route paths don't update automatically when the language is changed.

like image 912
butaminas Avatar asked Aug 05 '26 05:08

butaminas


1 Answers

Adding Routes

Dynamic routing is achieved mainly via two functions: router.addRoute() and router.removeRoute().

https://router.vuejs.org/guide/advanced/dynamic-routing.html#adding-routes

like image 177
artoju Avatar answered Aug 07 '26 20:08

artoju