vue设置选中时的样式名称

第一种方式:在router中全局设置

export default new Router({
  mode:'history',
  linkActiveClass:'index',
  routes: [
    {
      path: '/',
      name: 'index',
      redirect:{
        path:'/home'
      }
    },
    {
      path: '/home',
      name: 'home',
      component: Home
    }
  ]
})

第二种方式:在单条路由中设置 active-class

<router-link :to="{name:'home'}" event="mouseover" active-class="homeActive">
        home
      </router-link>

原文地址:https://www.cnblogs.com/javascripter/p/10516933.html