副标题
v-subheader
组件用于分隔列表的各个部分。
用例
最简单形式的副标题显示带有默认主题的副标题。
template
<template>
<v-subheader>Subheader</v-subheader>
</template>
API
从下面选择您想要的组件,并查看可用的属性、插槽、事件和函数。
实战场
template script
<template>
<div class="grey lighten-5 pa-4">
<v-row
align="center"
justify="center"
>
<v-col
cols="12"
md="8"
sm="4"
>
<v-card>
<v-subheader :inset="inset">Subheader</v-subheader>
<v-list>
<template v-for="(item, index) in items">
<v-list-item
v-if="item.action"
:key="item.title"
@click=""
>
<v-list-item-action>
<v-icon>{{ item.action }}</v-icon>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>{{ item.title }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-divider
v-else-if="item.divider"
:key="index"
></v-divider>
</template>
</v-list>
</v-card>
</v-col>
</v-row>
<v-row
class="mt-12"
align="center"
justify="center"
>
<v-col
cols="12"
md="8"
>
<template>
<v-checkbox
v-model="inset"
hide-details
label="Inset"
light
></v-checkbox>
</template>
</v-col>
</v-row>
</div>
</template>
<script>
export default {
data: () => ({
inset: false,
items: [
{
action: 'inbox',
title: 'inbox',
},
{
divider: true,
},
{
action: 'send',
title: 'send',
},
{
divider: true,
},
{
action: 'delete',
title: 'trash',
},
],
}),
}
</script>
示例
下面是一些简单到复杂的例子。
内嵌副标题
内嵌副标题向右移动 72px。 这使您可以选择将它们与列表项和插入分隔符对齐。
template script
<template>
<v-col cols="12" sm="6" offset-sm="3">
<v-card>
<v-subheader :inset="inset">Subheader</v-subheader>
<v-list>
<template v-for="(item, index) in items">
<v-list-item
v-if="item.action"
:key="item.title"
@click=""
>
<v-list-item-action>
<v-icon>{{ item.action }}</v-icon>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>{{ item.title }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-divider
v-else-if="item.divider"
:key="index"
:inset="inset"
></v-divider>
</template>
</v-list>
</v-card>
</v-col>
</template>
<script>
export default {
data: () => ({
inset: true,
items: [
{
action: 'label',
title: 'List item 1',
},
{
divider: true,
},
{
action: 'label',
title: 'List item 2',
},
{
divider: true,
},
{
action: 'label',
title: 'List item 3',
},
],
}),
}
</script>
栅格副标题
一个副标题可以添加上下文到用户正在看的东西。
template
<template>
<v-row>
<v-col cols="12" sm="6" offset-sm="3">
<v-card>
<v-toolbar color="white" flat>
<v-btn icon light>
<v-icon color="grey darken-2">mdi-arrow-left</v-icon>
</v-btn>
<v-toolbar-title class="grey--text text--darken-4">Albums</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn icon light>
<v-icon color="grey darken-2">mdi-magnify</v-icon>
</v-btn>
</v-toolbar>
<v-subheader>May</v-subheader>
<v-container fluid>
<v-row>
<v-col
v-for="i in 6"
:key="i"
cols="4"
>
<img
:src="`https://randomuser.me/api/portraits/men/${i + 20}.jpg`"
alt="lorem"
class="image"
height="100%"
width="100%"
>
</v-col>
</v-row>
</v-container>
<v-subheader>June</v-subheader>
<v-container fluid>
<v-row>
<v-col
v-for="i in 6"
:key="i"
cols="4"
>
<img
:src="`https://randomuser.me/api/portraits/women/${i + 5}.jpg`"
alt="lorem"
class="image"
height="100%"
width="100%"
>
</v-col>
</v-row>
</v-container>
<v-footer class="mt-12"></v-footer>
</v-card>
</v-col>
</v-row>
</template>
Enterprise support through Tidelift
The Tidelift Subscription is a managed open source subscription for application dependencies.
ads by Vuetify
]($a0bade116661502f.md)
菜单副标题
使用副标题可以帮助分离不同类型的操作。
template script
<template>
<v-row>
<v-col cols="12" sm="6" offset-sm="3">
<v-card>
<v-toolbar color="teal" dark>
<v-app-bar-nav-icon></v-app-bar-nav-icon>
<v-toolbar-title>Manage</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn icon>
<v-icon>mdi-dots-vertical</v-icon>
</v-btn>
</v-toolbar>
<v-list>
<template v-for="(item, index) in items">
<v-list-item
v-if="item.action"
:key="item.title"
@click=""
>
<v-list-item-action>
<v-icon>{{ item.action }}</v-icon>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>{{ item.title }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-divider
v-else-if="item.divider"
:key="index"
></v-divider>
<v-subheader
v-else-if="item.header"
:key="item.header"
>
{{ item.header }}
</v-subheader>
</template>
</v-list>
</v-card>
</v-col>
</v-row>
</template>
<script>
export default {
data () {
return {
items: [
{
action: 'move_to_inbox',
title: 'Inbox',
},
{
action: 'send',
title: 'Sent',
},
{
action: 'delete',
title: 'Trash',
},
{
action: 'report',
title: 'Spam',
},
{ divider: true },
{ header: 'Labels' },
{
action: 'label',
title: 'Family',
},
{
action: 'label',
title: 'Friends',
},
{
action: 'label',
title: 'Work',
},
],
}
},
}
</script>
带社交媒体的副标题
在社交媒体互动中使用子标题。
template script
<template>
<v-card
flat
tile
>
<v-toolbar
color="cyan"
dark
>
<v-app-bar-nav-icon></v-app-bar-nav-icon>
<v-toolbar-title>Application</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn icon>
<v-icon>mdi-magnify</v-icon>
</v-btn>
</v-toolbar>
<v-container
v-for="type in types"
:key="type"
class="grey lighten-4"
fluid
>
<v-subheader>{{ type }}</v-subheader>
<v-row>
<v-spacer></v-spacer>
<v-col
v-for="card in cards"
:key="card"
cols="12"
sm="6"
md="4"
>
<v-card>
<v-img
:src="`https://picsum.photos/200/300?image=${getImage()}`"
height="300px"
>
<span
class="headline white--text pl-4 pt-4"
v-text="card.title"
></span>
</v-img>
<v-card-actions class="white justify-center">
<v-btn
v-for="(social, i) in socials"
:key="i"
:color="social.color"
class="white--text"
fab
icon
small
>
<v-icon>{{ social.icon }}</v-icon>
</v-btn>
</v-card-actions>
</v-card>
</v-col>
</v-row>
</v-container>
</v-card>
</template>
<script>
export default {
data: () => ({
types: ['Places to Be', 'Places to See'],
cards: ['Good', 'Best', 'Finest'],
socials: [
{
icon: 'mdi-facebook',
color: 'indigo',
},
{
icon: 'mdi-linkedin',
color: 'cyan darken-1',
},
{
icon: 'mdi-instagram',
color: 'red lighten-3',
},
],
}),
methods: {
getImage () {
const min = 550
const max = 560
return Math.floor(Math.random() * (max - min + 1)) + min
},
},
}
</script>