[Vuejs]-VueRouter – how to reset certain state on every route change

3👍

You could use the Watched property of Vue to watch for changes in your route like:

watch: {
    $route(to, from) {
      console.log("route changed");
      this.someVariable = false;
    }
  }

More about the Route Object in the documentation.

Leave a comment