获取vue路由跳转路径

平时BUG:

  在vue中使用element ui 中的导航组件时,使用index作为跳转的路径,单击跳转没有问题,但是当刷新页面是,选项卡的激活
状态就变成初始化的了,起起初想到用获取window.location.search方法,效果是可以达到,但是后来发现这操作有的牵强,就换成了vue中
自己的获取路由路径的方式,如下:

1 let cur_path = this.$route.path;                 //获取当前路由
2 let routers = this.$router.options.routes;   // 获取路由对象
3 this.activeIndex=cur_path.replace("/","");
4 if(cur_path.indexOf("SystemSetup") > 0){
5 this.activeIndex='SystemSetup'
6 }
原文地址:https://www.cnblogs.com/hlrblog/p/9466838.html