[Vuejs]-Vue method runs even if I change route, how to run method only if I am on a specific route/component?

0👍

Try this in Home.vue:

beforeDestroy() {
  this.scroll = null
  delete this.scroll
}

It happens because, when changing route, the scroll() method is still mounted. This should prevent it from being loaded elsewhere than in Home.vue.

Leave a comment