简体   繁体   English

Vuetify工具栏被导航抽屉遮盖

[英]Vuetify toolbar obscured by navigation drawer

I would like an application layout that has a fixed toolbar at the top and a left-hand navigation drawer underneath. 我想要一个应用程序布局,该布局在顶部具有固定的工具栏,在下面具有左侧的导航抽屉。 In addition the navigation drawer should behave as "temporary", ie the user can click outside of the drawer to dismiss it. 另外,导航抽屉应表现为“临时”,即用户可以在抽屉外部单击以将其关闭。

I can get the visual effect I want with a non-temporary drawer, but this does not react to mouse clicks outside. 我可以使用非临时抽屉获得所需的视觉效果,但这不会对外部鼠标单击产生反应。 When it is marked as temporary it behaves correctly but visually is rendered over the top of the toolbar. 当将其标记为临时时,它的行为正确,但是在工具栏顶部视觉上呈现。

How can I ensure the navigation drawer is always rendered below the toolbar and does not obscure it AND is dismissed when the user clicks outside? 如何确保导航抽屉始终显示在工具栏下方,并且不会遮挡它,并且在用户单击外部时将其关闭?

See this codepen example 请参阅此Codepen示例

  <div id="app">
    <v-app id="inspire" >
      <v-navigation-drawer clipped app :temporary="temporary" v-model="drawer" hide-overlay>
      <v-list dense>
        <v-list-tile>I must respect the Toolbar and appear below</v-list-tile>
        <v-list-tile>Home 1</v-list-tile>
        <v-list-tile>Home 2</v-list-tile>
        <v-list-tile>Home 3</v-list-tile>
        <v-list-tile>Home 4</v-list-tile>
      </v-list>
    </v-navigation-drawer>

    <v-toolbar color="blue darken-3" dark app clipped-left>
      <v-btn @click="drawer = !drawer">Show drawer</v-btn>
      <v-toolbar-title>Toolbar should be always on top!</v-toolbar-title>
      <v-spacer></v-spacer>
      <v-switch v-model="temporary" label="Make drawer temporary" hide-details/>
    </v-toolbar>

    <v-content>
      <v-container fluid fill-height>
        nothing to see here
      </v-container>
    </v-content>

  </v-app>
</div>

javascript: JavaScript的:

  new Vue({
    el: "#app",
    data: () => ({
      drawer: false,
      temporary: false
    })
  });

Ok so it seems that what you are experiencing is the expected behaviour so this is not an issue with Vuetify, however you can achieve what you are describing by adding your own overlay. 好的,看来您正在体验的是预期的行为,因此这对Vuetify而言不是问题,但是您可以通过添加自己的叠加层来实现所描述的内容。

simply add your own overlay that is shown only when drawer is present, give it the relevant styling to fill the page and the correct z-index to sit between the page and the drawer. 只需添加您自己的叠加层(仅当抽屉存在时才显示),为其提供相关样式以填充页面,并为其提供正确的z索引以位于页面和抽屉之间。 Then just apply an @click to set drawer to false. 然后只需应用@click将抽屉设置为false。

<div v-if="drawer" class="custom_overlay" @click="drawer = !drawer"></div>

.custom_overlay {
    position: fixed;
    height: 100vh;
    width: 100%;
    background: rgba(50,50,50,0.5);
    z-index:2;
}

See example here: https://codepen.io/anon/pen/YoLwgv 在此处查看示例: https//codepen.io/anon/pen/YoLwgv

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

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