v-navigation-drawer and v-app-bar don't work as intended
·
Answer a question
I have made a simple app bar and navigation drawer page. But my v-navigation-drawer
component doesn't seem to be placed under my v-app-bar
component. The official vuetify documentation on the v-app
component makes it clear that this shouldn't be this way (How it should be).
My goal is to use the official layout because it is prettier than what I have now. I have tried using numerous props on both the v-app-bar
and v-navigation-drawer
component, but I can't seem to get it to work.
EDIT: My code is loaded as a component
in my main App.vue
My current code:
<template>
<div>
<v-app-bar app clipped-leftS flat dark>
<v-toolbar-title>
<span class="first-word font uppercase">hi</span>
<span class="second-word font uppercase">stackoverflow</span>
</v-toolbar-title>
<v-spacer></v-spacer>
</v-app-bar>
<v-navigation-drawer app flat dark mini-variant permanent expand-on-hover>
<v-list>
<v-list-item class="px-2">
<v-list-item-avatar>
<v-img src="https://randomuser.me/api/portraits/men/11.jpg"></v-img>
</v-list-item-avatar>
<v-list-item-title>John Doe</v-list-item-title>
</v-list-item>
<v-list-item v-for="item in navbarlist" :key="item.route" :to="item.route">
<v-list-item-icon>
<v-icon>{{ item.icon }}</v-icon>
</v-list-item-icon>
<v-list-item-content>{{ item.text }}</v-list-item-content>
</v-list-item>
</v-list>
</v-navigation-drawer>
</div>
</template>
<script>
export default {
data: () => ({
navbarlist: [
{ icon: "mdi-view-dashboard", text: "Dashboard", route: "/" },
{ icon: "mdi-upload", text: "Upload", route: "/upload" },
],
}),
};
</script>
<style>
.font {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
}
.uppercase {
text-transform: uppercase;
}
.first-word {
font-weight: 400;
}
.second-word {
font-weight: 200;
color: grey;
}
.item-tile-icon {
color: black;
}
</style>
Answers
I fixed it by adding clipped
to my v-navigation-drawer
component.
So my final code is:
<template>
<div>
<v-app-bar app clipped-left flat dark>
<v-toolbar-title>
<span class="first-word font uppercase">hi</span>
<span class="second-word font uppercase">stackoverflow</span>
</v-toolbar-title>
<v-spacer></v-spacer>
</v-app-bar>
<v-navigation-drawer app clipped flat dark expand-on-hover>
<v-list>
<v-list-item class="px-2">
<v-list-item-avatar>
<v-img src="https://randomuser.me/api/portraits/men/11.jpg"></v-img>
</v-list-item-avatar>
<v-list-item-title>John Doe</v-list-item-title>
</v-list-item>
<v-list-item v-for="item in navbarlist" :key="item.route" :to="item.route">
<v-list-item-icon>
<v-icon>{{ item.icon }}</v-icon>
</v-list-item-icon>
<v-list-item-content>{{ item.text }}</v-list-item-content>
</v-list-item>
</v-list>
</v-navigation-drawer>
</div>
</template>
更多推荐
所有评论(0)