我正在尝试使用Vuetify创建一个侧边栏,顶部将有一些常见操作,而用户头像将在底部。
我正在使用v-navigation-drawer
,到目前为止,我已经提出了这个建议:
<template>
<v-navigation-drawer
app
permanent
mini-variant="true"
class="cyan lighten-3"
>
<v-list>
<!-- Timeline action -->
<v-list-tile>
<v-list-tile-action>
<v-btn
flat
exact
icon
color="white"
>
<v-icon>timeline</v-icon>
</v-btn>
</v-list-tile-action>
</v-list-tile>
<!-- Sms action -->
<v-list-tile>
<v-list-tile-action>
<v-btn
flat
exact
icon
color="white"
>
<v-icon>sms</v-icon>
</v-btn>
</v-list-tile-action>
</v-list-tile>
<!-- Calendar action -->
<v-list-tile>
<v-list-tile-action>
<v-btn
flat
exact
icon
color="white"
>
<v-icon>calendar_today</v-icon>
</v-btn>
</v-list-tile-action>
</v-list-tile>
<!-- Settings Action -->
<v-list-tile>
<v-list-tile-action>
<v-btn
flat
exact
icon
color="white"
>
<v-icon>settings</v-icon>
</v-btn>
</v-list-tile-action>
</v-list-tile>
</v-list>
<v-divider></v-divider>
<!--This should be the avatar but I used a btn for demo purposes-->
<v-btn
flat
exact
icon
bottom
color="red"
>
<v-icon>timeline</v-icon>
</v-btn>
</v-navigation-drawer>
</template>
<!-- <script> and <style> follow after this-->
因此,如您所见,在我使用v-list
之后,我使用了v-divider
并将图标(或头像)放在下面。
问题是我不能完全将其移到v-navigation-drawer
的底部。我尝试在v-flex
和最后一个v-list
周围使用v-btn
,但无济于事。
我在这里想念什么?
答案 0 :(得分:5)
您可以像这样在导航抽屉组件内使用插槽:
<template v-slot:append>
<div class="pa-2">
<v-btn block>Logout</v-btn>
</div>
</template>
答案 1 :(得分:2)
用v-layout
,justify-space-between
和column
道具在fill-height
中包裹您的导航列表和头像:
Vue.use(Vuetify)
new Vue({
el: '#app',
data: () => ({
drawer: true
})
})
<link href='https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons' rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/vuetify/dist/vuetify.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.22/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify/dist/vuetify.js"></script>
<v-app id="app">
<v-navigation-drawer v-model="drawer" fixed app>
<v-layout fill-height column justify-space-between>
<v-list dense>
<v-list-tile @click="">
<v-list-tile-action>
<v-icon>home</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title>Home</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
<v-list-tile @click="">
<v-list-tile-action>
<v-icon>contact_mail</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title>Contact</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
</v-list>
<v-avatar color="red">
<v-icon dark>account_circle</v-icon>
</v-avatar>
</v-layout>
</v-navigation-drawer>
<v-toolbar color="indigo" dark fixed app>
<v-toolbar-side-icon @click.stop="drawer = !drawer"></v-toolbar-side-icon>
<v-toolbar-title>Application</v-toolbar-title>
</v-toolbar>
<v-content>
<v-container fluid fill-height>
<v-layout justify-center align-center>
<v-flex text-xs-center>
</v-flex>
</v-layout>
</v-container>
</v-content>
</v-app>
答案 2 :(得分:1)
将justify-end
添加到按钮并用v-layout
和column
将fill-height
中的btn换行并为您完成以下工作:https://codepen.io/anon/pen/daMXqp?editors=1000
<v-layout align-center justify-space-between column fill-height>
<v-list>
...
</v-list>
<v-btn
justify-end
flat
exact
icon
color="green"
><v-icon>dashboard</v-icon></v-btn>
</v-layout>
答案 3 :(得分:0)
似乎仅将fill-height
添加到v-layout
即可填充元素的高度,因此,您接下来添加的任何其他元素都将被迫位于底部。