第一种方式:在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>