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

时间:2018-10-17 16:19:55

标签: javascript vue.js vuex vue-router

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

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

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

1 个答案:

答案 0 :(得分:2)

您可能正在寻找的是:

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

或者简单地

console.log(this.$route);

获取有关当前路线的所有信息

相关问题