在根组件APP.vue中的导航标签中设置了三个router-link,每当我切换路由时,如何才能获取到当前点击的路由地址?
<nav :class="{ active: isbgc }" >
<router-link to="/statorview">Stator</router-link> |
<router-link to="/rotorview">Rotor</router-link> |
<router-link to="/searchview" @click.native="changeBGC">Search</router-link>
</nav>
changeBGC () {
const arr = this.$router.options.routes
// console.log('我是路径数组', arr)
const path = arr.map(item => {
// console.log('我是数组对象', item.path) // 循环出数组对象
return item.path
})
if ( === '/searchview') return this.isbgc === true
}
this.$route.path