简体   繁体   English

在Vuetify 1.5中,如何在v-toolbar中获得美观的v-menu?

[英]In Vuetify 1.5 how do I get a v-menu look good in v-toolbar?

This is my toolbar, and I have problems with the the first button/menu. 这是我的工具栏,第一个按钮/菜单有问题。 I want it, when highlighted to have the same look as when the other buttons are highlighted. 我希望它在突出显示时具有与其他按钮突出显示时相同的外观。 I've tried with py-3 and py-2 class on the v-btn, but then it gets squeed or does not fill the entire toolbar erea. 我已经尝试过在v-btn上使用py-3和py-2类,但是随后它被挤​​压或无法填充整个工具栏区域。

 <v-toolbar dark dense app color="blue-grey darken-2">
  <v-toolbar-side-icon @click="drawer = !drawer"></v-toolbar-side-icon>
  <v-toolbar-title class="text-uppercase">
    <router-link :to="{ name: 'home' }" class="brand-logo white--text">
      <span>Byte</span>
      <span class="font-weight-light">[Gym]</span>
    </router-link>
  </v-toolbar-title>
  <v-spacer></v-spacer>
  <v-toolbar-items class="hidden-sm-and-down">
    <v-menu v-if="user" offset-y transition="slide-y-transition" open-on-hover>
      <template v-slot:activator="{ on }">
        <v-btn flat v-on="on">
          <v-icon>expand_more</v-icon><v-btn flat to="/training">Training</v-btn>
        </v-btn>
      </template>
      <v-list>
        <v-list-tile v-for="item in traininglinks" :key="item.text" router :to="item.route">
          <v-list-tile-title>{{ item.text }}</v-list-tile-title>
        </v-list-tile>
      </v-list>
    </v-menu>
    <v-btn flat to="/nutrition">Nutrition</v-btn>
    <v-btn flat to="/about">About</v-btn>
  </v-toolbar-items>
  <v-spacer></v-spacer>
  <v-btn v-if="user" flat>{{user.email}}</v-btn>
  <v-btn v-if="!user" icon to="/login">
    <v-icon>account_circle</v-icon>
  </v-btn>
  <v-btn v-if="user" icon @click="logout">
    <v-icon right>exit_to_app</v-icon>
  </v-btn>
  <v-btn icon>
    <v-icon>search</v-icon>
  </v-btn>
  <v-btn icon class="hidden-sm-and-up">
    <v-icon>more_vert</v-icon>
  </v-btn>
</v-toolbar>

I want it to look like the other buttons when they are active, but now its only a tiny box around it. 我希望它在激活时看起来像其他按钮,但是现在它周围只有一个小方框。 I feels this should work out of the box? 我觉得这应该开箱即用吗? Can't find an answer for this anywhere.. 在任何地方都找不到答案。

营养突出 培训突出 挤

So the problem here is that you're putting a button inside of a button. 所以这里的问题是,您要将按钮放在按钮内部。 If you remove the v-btn around Training then it works the way it's supposed to. 如果您删除了Training周围的v-btn ,则它会按照预期的方式工作。

      <template v-slot:activator="{ on }">
        <v-btn flat v-on="on">
          <v-icon>expand_more</v-icon>Training
        </v-btn>
      </template>

Working codepen here: https://codepen.io/CodingDeer/pen/rNBjLOJ?editors=1010 此处可工作的codepen: https ://codepen.io/CodingDeer/pen/rNBjLOJ ? editors = 1010

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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