【问题标题】:How to get current route name in Component?如何在组件中获取当前路由名称?
【发布时间】:2018-10-17 16:19:54
【问题描述】:

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

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

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

【问题讨论】:

    标签: javascript vue.js vuex vue-router


    【解决方案1】:

    您可能正在寻找的是:

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

    或者干脆

    console.log(this.$route);

    获取当前路线的所有信息

    【讨论】:

      猜你喜欢
      • 2016-05-09
      • 2017-11-28
      • 1970-01-01
      • 1970-01-01
      • 2020-10-04
      • 1970-01-01
      • 2018-10-07
      • 2018-07-05
      • 1970-01-01
      相关资源
      最近更新 更多