简体   繁体   中英

Vuetify <v-toolbar-title> and links that do not change formating

It looks like you can use the to in so the router link extends. I want to make the link to the the front page. does not work and wrapping in changes the formatting. How can I make <-v-toolbar-title> link without changing the formatting? Thanks!

There is a perfect way to handle this situation.

Use click event handler to navigate to the front page

Just replace your v-toolbar-title code with the following code.

<v-toolbar-title @click="$router.push('/')" class="headline text-uppercase" >
  <span class="display-1 text-uppercase font-weight-medium">Company&nbsp;</span>
  <span class="display-1 text-uppercase font-weight-light">Associates</span>
</v-toolbar-title>

This way its very clean without adding any external css or additional button component just by adding this "$router.push('/')" to @click event handler

I'm not sure you'll be content with any response to this issue because it'll involve at least some customization.

If you're not happy with the other solutions here is another one: https://codepen.io/simondepelchin/pen/PooRyBG

What I did is replace the v-toolbar-title with a router-link and manually added the v-toolbar__title class that is added by Vuetify. Also note that in order to keep default styling you have to specify the link's tag which should be div in this case.

Here's the code snippet:

<router-link 
    tag="div"
    :to="{ path: '/' }" 
    class="v-toolbar__title headline text-uppercase">
    <span class="display-1 text-uppercase font-weight-medium">Company&nbsp;</span>
    <span class="display-1 text-uppercase font-weight-light">Associates</span>
</router-link>

Just be aware that in case Vuetify updates and changes the class used for the v-toolbar-title you might have to change it too.

A quick fix is the below one. There is no out of the box solution as fas as I know.

<v-toolbar-title>
    <v-btn text to="/">home</v-btn>
</v-toolbar-title>
.theme--light.v-btn--active:hover::before,
.theme--light.v-btn--active::before {
  opacity: 0;
}

.theme--dark.v-btn--active:hover::before,
.theme--dark.v-btn--active::before {
  opacity: 0;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM