Vue Lifecycle?

there are three routing components in a page: the created method is called only when the routing component jumps in for the first time. Is there a method that will be called automatically every time you jump to this routing page?

Mar.03,2021

  1. mounted; in the lifecycle
  2. Guards within components
beforeRouteEnter
beforeRouteUpdate (2.2 )
beforeRouteLeave

clipboard.png


write mounted in a subcomponent or use the vue-router hook function


is it possible that this requirement needs to listen for routing changes to handle the corresponding changes?

watch: {
  $route() {
    // do somethings ...
  }
}

every time you jump to this routing page, isn't watch listening on the route?

watch: {
    $route(to,from){
    // to => route
    // from => route
    this._getData(); // todo
}
Menu