[Vuejs]-How to re-render already mounted component after route change in vue?

1👍

Vue can reuse the instance, when the component is same, so the this.$route in the component will change but created(), beforeMounted() and mounted() hooks won’t be called.

To force vue to create a new component instance you can set a unique key on the like <router-view :key="$route.fullPath">

Another options is to react to changes in the $route with a watcher:

watch: {
  "$route.params.cname": {
    handler(cname) {
      // do stuff
    },
    immediate: true
  }
}
👤haMzox

0👍

The best solution seems to be use a watcher to watch $route and call a function on $route change

👤jeff

Leave a comment