How to VueJS router-link active style

前端 未结 5 781
予麋鹿
予麋鹿 2020-12-07 12:16

My page currently has Navigation.vue component. I want to make the each navigation hover and active. The \'hover\' works but \'active\' doesn\'t.

This is how Na

5条回答
  •  粉色の甜心
    2020-12-07 12:32

    Just add to @Bert's solution to make it more clear:

        const routes = [
      { path: '/foo', component: Foo },
      { path: '/bar', component: Bar }
    ]
    
    const router = new VueRouter({
      routes,
      linkExactActiveClass: "active" // active class for *exact* links.
    })
    

    As one can see, this line should be removed:

    linkActiveClass: "active", // active class for non-exact links.
    

    this way, ONLY the current link is hi-lighted. This should apply to most of the cases.

    David

提交回复
热议问题