Search code examples
javascriptvue.jsvuexvue-router

How to get current route name in Component?


I want to get current route name in controller. I tried: this.route, this.curentRoute, this._routerRoot but Nothing Works.

computed: {
    currentRoute:{
      get(){
        console.log(this.__routerRoot);
      }
    },
}

How to get router name? Thanks


Solution

  • Probably what you are looking for is:

    console.log(this.$route.name);

    or simply

    console.log(this.$route);

    to get all the informations about the current route