Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vuetify v-btn routing active class issues

I'm writing a CRUD app using Vue with Vuetify. I have some links defined as v-btns using the "to" attribute. I've noticed that when clicking on buttons, the active button usually changes so that the button corresponding to the user's current location is highlighted. However, I have two routes that look like this:

"/songs/new"
"/songs"

The v-btn's have the following "to" attributes:

to:"/songs/new"
to:"/songs"

However, when clicking on the button that directs to "/songs/new", vuetify sets both buttons to be active. Any idea why it does this?

like image 912
Alex Leibowitz Avatar asked Aug 19 '18 19:08

Alex Leibowitz


1 Answers

You need to make use of exact attribute.

<v-btn to="/songs/new" exact>Songs</v-btn>
<v-btn to="/songs" exact>New Song</v-btn>

Now the button will get active class only if you were in exactly route.

Also you can make use of exact-active-class to use custom active classes.

like image 76
Renan Coelho Avatar answered Oct 22 '22 13:10

Renan Coelho