Vuetify: Why is the sidebar laying over the other element?

被刻印的时光 ゝ 提交于 2021-01-29 16:22:07

问题


My sidebar is laying over the router-view but it should be "blocking" the space.

In my App.vue there is following code

<template>
    <v-app id="app">
        <v-container>
            <sidebar class="d-block"/>

            <router-view class="d-block"></router-view>
        </v-container>
    </v-app>
</template>

Due to the d-block class of Vuetify I'd expect the sidebar to not overlay.

The sidebar is basically copied from the original API

<template>
    <v-container>
        <v-navigation-drawer
        v-model="drawer"
        :color="color"
        :permanent="permanent"
        :app="app"
        dark
        >
            <v-list dense nav class="py-0">
                <v-list-item-content>
                    <v-list-item-title>Application</v-list-item-title>
                    <v-list-item-subtitle>Subtext</v-list-item-subtitle>
                </v-list-item-content>

                <v-divider></v-divider>

                <v-list-item v-for="item in items" :key="item.title" link>
                <v-list-item-icon>
                    <v-icon>{{ item.icon }}</v-icon>
                </v-list-item-icon>

                <v-list-item-content>
                    <v-list-item-title>{{ item.title }}</v-list-item-title>
                </v-list-item-content>
                </v-list-item>
            </v-list>
        </v-navigation-drawer>
    </v-container>
</template>

回答1:


I'm not familiar with the d-block class, and a search of the Vuetify docs didn't show me anything. I would get rid of it; you don't need a d-block class to make the navigation drawer push the content aside when it opens.

That being said, I don't think you want to wrap everything in <v-container> like you're doing. Try structuring your app code like this:

<template>
  <v-app id="app">
    <sidebar />
    <v-content>
      <router-view />
    </v-content>
  </v-app>
</template>

And don't wrap your <v-navigation-drawer> in <v-container>, either. You want it like this:

<template>
  <v-navigation-drawer
    v-model="drawer"
    permanent
    app
    dark
    color="primary"
  >
    // Contents
  </v-navigation-drawer>
</template>

Then, have the views displayed by your <router-view> use <v-container>:

<template>
  <v-container class="fill-height" fluid>
    // View content
  </v-container>
</template>


来源:https://stackoverflow.com/questions/61855927/vuetify-why-is-the-sidebar-laying-over-the-other-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!