[Vuejs]-Navigating to a new optional base route while maintaining the current nested routes – Vue Router

0πŸ‘

βœ…

With help from Posva from Vue I was able to solve this.

My approach and understanding of how Vue Router worked was slightly incorrect by thinking that you needed to reference the named route in a nested tree that you wanted to update.

To update the Transport type in /euope/spain I would need to instead reference the Country named route and update the param for the transport.

<router-link :to="{
    name: 'Country',
    params: {
        transportSlug: filter.slug,
    }
}">

This maintains the correct URL while updating the Transport type.

Hope this may be of some help to someone.

Leave a comment