Reputation: 179
I am using vuetify.js. I wanted to application title to link to top menu. But in /route shop and /discount the HogeHoge button changed toggled state. Is there any way to collect this?
<v-toolbar app>
<v-toolbar-title class="mr-5">
<v-btn flat to="/">HogeHoge</v-btn>
</v-toolbar-title>
<v-toolbar-items class="hidden-sm-and-down">
<v-btn flat to="/shop">shop</v-btn>
<v-btn flat to="/discount">discount</v-btn>
</v-toolbar-items>
</v-toolbar>
Upvotes: 10
Views: 14264
Reputation: 450
Here is how I solved it. I followed a mix of vuetify and vue-router official documentation.
<v-toolbar-title style="cursor: pointer">
<router-link v-slot="{navigate}" :to="{ name:'Home' }" custom>
<span role="link" @click="navigate" @keypress.enter="navigate">
Home
</span>
</router-link>
</v-toolbar-title>
It is important to highlight some things on this answer:
Upvotes: 0
Reputation: 5153
Simply edit v-toolbar-title tag to include the following:
<v-toolbar-title style="cursor: pointer" @click="$router.push('/')" >
Upvotes: 7
Reputation: 101
<router-link to="/home" tag="div" class="v-toolbar__title">Home</router-link>
And you can do it with any element. Just you need to know which vuetify class name you should use.
If you dont know what class name is it just at first try implement normal element which will be a router link.
<v-toolbar-title>Title</v-toolbar-title>
Open your dev tools browser and copy class name (and tag also).
Now you can do the trick with router link.
Upvotes: 2
Reputation: 2280
You can do this by simply wrapping it in a router-link
.
<v-toolbar app clipped-left>
<router-link to="/page1">
<v-toolbar-title>
🏠 Title
</v-toolbar-title>
</router-link>
</v-toolbar>
In Nuxt js
you can do like this:
<nuxt-link to="/page1">
<v-toolbar-title>
🏠 Title
</v-toolbar-title>
</nuxt-link>
Upvotes: 4
Reputation: 179
I could self solve this. Doing active-class noting to root route.
https://github.com/vuetifyjs/vuetify/issues/1947
Upvotes: 0
Reputation: 2153
You can add exact as prop, as:
<v-btn flat to="/shop" exact>shop</v-btn>
<v-btn flat to="/discount" exact>discount</v-btn>
Upvotes: 3