[Vuejs]-How to use the same component for nested routes routes in vue-router

1👍

One possible solution is add :key to your router-view to force it re-render

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

You can also watch $route inside singleItemView.vue to have custom action (for example, call API)

watch: {
  '$route'(to, from) {
    const {id, subId} = to.params
    if (subId) {
      // do something
    } else {
      // do something else
    }
  }
},
👤ittus

Leave a comment