如何在组件中获取当前路由名称?

How to get current route name in Component?

我想在控制器中获取当前路由名称。 我尝试了:this.route、this.curentRoute、this._routerRoot 但没有任何效果。

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

如何获取路由器名称? 谢谢

可能您要找的是:

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

或者干脆

console.log(this.$route);

获取当前路线的所有信息