[Vuejs]-Vue-Router won't work when a route is activated

2👍

You need to watch for param changes in the $route and perform the correct action (e.g. making an ajax call to retrieve the information for the given id), so:

watch: {
  '$route' (to, from) {
   // React to route change
 }
}

You may also use the beforeRouteUpdate guard (see: https://router.vuejs.org/en/essentials/dynamic-matching.html)

1👍

You can also add a unique key attribute to the router-view so that vue forcefully replaces the component instead of reusing it

<router-view :key="$route.path"></router-view>

Leave a comment