列表
v-list
组件用于显示信息,它可以包含一个头像、内容、操作、列表组标题等等。列表也可以包含子元素并在侧边栏(sidebar)使用。
如果您要查找有状态列表项,请查看 v-list-item-group。
用例
列表有三个主要变量。single-line (默认), two-line 和 three-line。 行声明指定了项目的最小高度,也可以使用相同的属性从 v-list
中进行控制。
template
<template>
<v-card
class="mx-auto"
max-width="400"
tile
>
<v-list-item>
<v-list-item-content>
<v-list-item-title>Single-line item</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-item two-line>
<v-list-item-content>
<v-list-item-title>Two-line item</v-list-item-title>
<v-list-item-subtitle>Secondary text</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
<v-list-item three-line>
<v-list-item-content>
<v-list-item-title>Three-line item</v-list-item-title>
<v-list-item-subtitle>
Secondary line text Lorem ipsum dolor sit amet,
</v-list-item-subtitle>
<v-list-item-subtitle>
consectetur adipiscing elit.
</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
</v-card>
</template>
API
从下面选择您想要的组件,并查看可用的属性、插槽、事件和函数。
实战场
template script
<template>
<v-row align="center">
<v-row justify="space-around">
<v-switch v-model="disabled" class="ma-2" label="Disabled"></v-switch>
<v-switch v-model="dense" class="ma-2" label="Dense"></v-switch>
<v-switch v-model="twoLine" class="ma-2" label="Two-line"></v-switch>
<v-switch v-model="threeLine" class="ma-2" label="Three-line"></v-switch>
<v-switch v-model="shaped" class="ma-2" label="Shaped"></v-switch>
<v-switch v-model="flat" class="ma-2" label="Flat"></v-switch>
<v-switch v-model="subheader" class="ma-2" label="Subheader"></v-switch>
<v-switch v-model="inactive" class="ma-2" label="Inactive"></v-switch>
<v-switch v-model="subGroup" class="ma-2" label="Sub-group"></v-switch>
<v-switch v-model="nav" class="ma-2" label="Nav"></v-switch>
<v-switch v-model="avatar" class="ma-2" label="Avatar"></v-switch>
<v-switch v-model="rounded" class="ma-2" label="Rounded"></v-switch>
</v-row>
<v-card
class="mx-auto"
max-width="400"
tile
>
<v-list
:disabled="disabled"
:dense="dense"
:two-line="twoLine"
:three-line="threeLine"
:shaped="shaped"
:flat="flat"
:subheader="subheader"
:sub-group="subGroup"
:nav="nav"
:avatar="avatar"
:rounded="rounded"
>
<v-subheader>REPORTS</v-subheader>
<v-list-item-group v-model="item" color="primary">
<v-list-item
v-for="(item, i) in items"
:key="i"
:inactive="inactive"
>
<v-list-item-avatar v-if="avatar">
<v-img :src="item.avatar"></v-img>
</v-list-item-avatar>
<v-list-item-content>
<v-list-item-title v-html="item.title"></v-list-item-title>
<v-list-item-subtitle v-if="twoLine || threeLine" v-html="item.subtitle"></v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
</v-list-item-group>
</v-list>
</v-card>
</v-row>
</template>
<script>
export default {
data: () => ({
item: 5,
items: [
{
avatar: 'https://cdn.vuetifyjs.com/images/lists/1.jpg',
title: 'Brunch this weekend?',
subtitle: "<span class='text--primary'>Ali Connors</span> — I'll be in your neighborhood doing errands this weekend. Do you want to hang out?",
},
{
avatar: 'https://cdn.vuetifyjs.com/images/lists/2.jpg',
title: 'Summer BBQ <span class="grey--text text--lighten-1">4</span>',
subtitle: "<span class='text--primary'>to Alex, Scott, Jennifer</span> — Wish I could come, but I'm out of town this weekend.",
},
{
avatar: 'https://cdn.vuetifyjs.com/images/lists/3.jpg',
title: 'Oui oui',
subtitle: "<span class='text--primary'>Sandra Adams</span> — Do you have Paris recommendations? Have you ever been?",
},
{
avatar: 'https://cdn.vuetifyjs.com/images/lists/4.jpg',
title: 'Birthday gift',
subtitle: "<span class='text--primary'>Trevor Hansen</span> — Have any ideas about what we should get Heidi for her birthday?",
},
{
avatar: 'https://cdn.vuetifyjs.com/images/lists/5.jpg',
title: 'Recipe to try',
subtitle: "<span class='text--primary'>Britta Holt</span> — We should eat this: Grate, Squash, Corn, and tomatillo Tacos.",
},
],
disabled: false,
dense: false,
twoLine: false,
threeLine: false,
shaped: false,
flat: false,
subheader: false,
inactive: false,
subGroup: false,
nav: false,
avatar: false,
rounded: false,
}),
}
</script>
示例
下面是一些简单到复杂的例子。
已禁用列表
您不能与禁用的 v-list
互动。
template script
<template>
<v-card
class="mx-auto"
max-width="300"
tile
>
<v-list disabled>
<v-subheader>REPORTS</v-subheader>
<v-list-item-group v-model="item" color="primary">
<v-list-item
v-for="(item, i) in items"
:key="i"
>
<v-list-item-icon>
<v-icon v-text="item.icon"></v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title v-text="item.text"></v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list-item-group>
</v-list>
</v-card>
</template>
<script>
export default {
data: () => ({
item: 1,
items: [
{ text: 'Real-Time', icon: 'mdi-clock' },
{ text: 'Audience', icon: 'mdi-account' },
{ text: 'Conversions', icon: 'mdi-flag' },
],
}),
}
</script>
形状列表
形状列表在 v-list-item
的一侧具有圆形边界。
template script
<template>
<v-card
class="mx-auto"
max-width="300"
tile
>
<v-list shaped>
<v-subheader>REPORTS</v-subheader>
<v-list-item-group v-model="item" color="primary">
<v-list-item
v-for="(item, i) in items"
:key="i"
>
<v-list-item-icon>
<v-icon v-text="item.icon"></v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title v-text="item.text"></v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list-item-group>
</v-list>
</v-card>
</template>
<script>
export default {
data: () => ({
item: 1,
items: [
{ text: 'Real-Time', icon: 'mdi-clock' },
{ text: 'Audience', icon: 'mdi-account' },
{ text: 'Conversions', icon: 'mdi-flag' },
],
}),
}
</script>
密集
v-list
可以通过 dense
属性变密集。
template script
<template>
<v-card
class="mx-auto"
max-width="300"
tile
>
<v-list dense>
<v-subheader>REPORTS</v-subheader>
<v-list-item-group v-model="item" color="primary">
<v-list-item
v-for="(item, i) in items"
:key="i"
>
<v-list-item-icon>
<v-icon v-text="item.icon"></v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title v-text="item.text"></v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list-item-group>
</v-list>
</v-card>
</template>
<script>
export default {
data: () => ({
item: 1,
items: [
{ text: 'Real-Time', icon: 'mdi-clock' },
{ text: 'Audience', icon: 'mdi-account' },
{ text: 'Conversions', icon: 'mdi-flag' },
],
}),
}
</script>
扁平
在 flat
属性的 v-list
中选择时,项目不会发生变化。
template script
<template>
<v-card
class="mx-auto"
max-width="300"
tile
>
<v-list flat>
<v-subheader>REPORTS</v-subheader>
<v-list-item-group v-model="item" color="primary">
<v-list-item
v-for="(item, i) in items"
:key="i"
>
<v-list-item-icon>
<v-icon v-text="item.icon"></v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title v-text="item.text"></v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list-item-group>
</v-list>
</v-card>
</template>
<script>
export default {
data: () => ({
item: 1,
items: [
{ text: 'Real-Time', icon: 'mdi-clock' },
{ text: 'Audience', icon: 'mdi-account' },
{ text: 'Conversions', icon: 'mdi-flag' },
],
}),
}
</script>
圆角
你可以让 v-list
项变成圆角。
template script
<template>
<v-card
class="mx-auto"
max-width="300"
tile
>
<v-list rounded>
<v-subheader>REPORTS</v-subheader>
<v-list-item-group v-model="item" color="primary">
<v-list-item
v-for="(item, i) in items"
:key="i"
>
<v-list-item-icon>
<v-icon v-text="item.icon"></v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title v-text="item.text"></v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list-item-group>
</v-list>
</v-card>
</template>
<script>
export default {
data: () => ({
item: 1,
items: [
{ text: 'Real-Time', icon: 'mdi-clock' },
{ text: 'Audience', icon: 'mdi-account' },
{ text: 'Conversions', icon: 'mdi-flag' },
],
}),
}
</script>
头像和列表项标题操作的组合
列表中还包含有插槽,可以采用更明确的方法。如果你选择了这种方法,请记住你必须提供额外的 props,以获得正确的间距。在这个例子中,我们有一个带头像的标题,所以我们必须提供一个 avatar
属性。
template script
<template>
<v-card
max-width="500"
class="mx-auto"
>
<v-toolbar
color="indigo"
dark
>
<v-app-bar-nav-icon></v-app-bar-nav-icon>
<v-toolbar-title>Inbox</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn icon>
<v-icon>mdi-magnify</v-icon>
</v-btn>
<v-btn icon>
<v-icon>mdi-dots-vertical</v-icon>
</v-btn>
</v-toolbar>
<v-list>
<v-list-item
v-for="item in items"
:key="item.title"
@click=""
>
<v-list-item-icon>
<v-icon v-if="item.icon" color="pink">mdi-star</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title v-text="item.title"></v-list-item-title>
</v-list-item-content>
<v-list-item-avatar>
<v-img :src="item.avatar"></v-img>
</v-list-item-avatar>
</v-list-item>
</v-list>
</v-card>
</template>
<script>
export default {
data () {
return {
items: [
{ icon: true, title: 'Jason Oner', avatar: 'https://cdn.vuetifyjs.com/images/lists/1.jpg' },
{ title: 'Travis Howard', avatar: 'https://cdn.vuetifyjs.com/images/lists/2.jpg' },
{ title: 'Ali Connors', avatar: 'https://cdn.vuetifyjs.com/images/lists/3.jpg' },
{ title: 'Cindy Baker', avatar: 'https://cdn.vuetifyjs.com/images/lists/4.jpg' },
],
}
},
}
</script>
具有两行内容加上图标的操作
列表组件可以包含列表组标题,分割线,以及1行或者更多行,如果副标题文本溢出则会以省略号的形式截断文本
template script
<template>
<v-card
max-width="600"
class="mx-auto"
>
<v-toolbar
color="light-blue"
dark
>
<v-app-bar-nav-icon></v-app-bar-nav-icon>
<v-toolbar-title>My files</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn icon>
<v-icon>mdi-magnify</v-icon>
</v-btn>
<v-btn icon>
<v-icon>mdi-view-module</v-icon>
</v-btn>
</v-toolbar>
<v-list two-line subheader>
<v-subheader inset>Folders</v-subheader>
<v-list-item
v-for="item in items"
:key="item.title"
@click=""
>
<v-list-item-avatar>
<v-icon
:class="[item.iconClass]"
v-text="item.icon"
></v-icon>
</v-list-item-avatar>
<v-list-item-content>
<v-list-item-title v-text="item.title"></v-list-item-title>
<v-list-item-subtitle v-text="item.subtitle"></v-list-item-subtitle>
</v-list-item-content>
<v-list-item-action>
<v-btn icon>
<v-icon color="grey lighten-1">mdi-information</v-icon>
</v-btn>
</v-list-item-action>
</v-list-item>
<v-divider inset></v-divider>
<v-subheader inset>Files</v-subheader>
<v-list-item
v-for="item in items2"
:key="item.title"
@click=""
>
<v-list-item-avatar>
<v-icon
:class="[item.iconClass]"
v-text="item.icon"
></v-icon>
</v-list-item-avatar>
<v-list-item-content>
<v-list-item-title v-text="item.title"></v-list-item-title>
<v-list-item-subtitle v-text="item.subtitle"></v-list-item-subtitle>
</v-list-item-content>
<v-list-item-action>
<v-btn icon>
<v-icon color="grey lighten-1">mdi-information</v-icon>
</v-btn>
</v-list-item-action>
</v-list-item>
</v-list>
</v-card>
</template>
<script>
export default {
data: () => ({
items: [
{ icon: 'folder', iconClass: 'grey lighten-1 white--text', title: 'Photos', subtitle: 'Jan 9, 2014' },
{ icon: 'folder', iconClass: 'grey lighten-1 white--text', title: 'Recipes', subtitle: 'Jan 17, 2014' },
{ icon: 'folder', iconClass: 'grey lighten-1 white--text', title: 'Work', subtitle: 'Jan 28, 2014' },
],
items2: [
{ icon: 'assignment', iconClass: 'blue white--text', title: 'Vacation itinerary', subtitle: 'Jan 20, 2014' },
{ icon: 'call_to_action', iconClass: 'amber white--text', title: 'Kitchen remodel', subtitle: 'Jan 10, 2014' },
],
}),
}
</script>
头像和三行内容的组合
对于三行列表,字幕将垂直夹在 2 行,然后省略。 此功能使用 line-clamp ,并不是所有浏览器都支持此功能。
template script
<template>
<v-card
max-width="450"
class="mx-auto"
>
<v-toolbar
color="cyan"
dark
>
<v-app-bar-nav-icon></v-app-bar-nav-icon>
<v-toolbar-title>Inbox</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn icon>
<v-icon>mdi-magnify</v-icon>
</v-btn>
</v-toolbar>
<v-list three-line>
<template v-for="(item, index) in items">
<v-subheader
v-if="item.header"
:key="item.header"
v-text="item.header"
></v-subheader>
<v-divider
v-else-if="item.divider"
:key="index"
:inset="item.inset"
></v-divider>
<v-list-item
v-else
:key="item.title"
@click=""
>
<v-list-item-avatar>
<v-img :src="item.avatar"></v-img>
</v-list-item-avatar>
<v-list-item-content>
<v-list-item-title v-html="item.title"></v-list-item-title>
<v-list-item-subtitle v-html="item.subtitle"></v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
</template>
</v-list>
</v-card>
</template>
<script>
export default {
data: () => ({
items: [
{ header: 'Today' },
{
avatar: 'https://cdn.vuetifyjs.com/images/lists/1.jpg',
title: 'Brunch this weekend?',
subtitle: "<span class='text--primary'>Ali Connors</span> — I'll be in your neighborhood doing errands this weekend. Do you want to hang out?",
},
{ divider: true, inset: true },
{
avatar: 'https://cdn.vuetifyjs.com/images/lists/2.jpg',
title: 'Summer BBQ <span class="grey--text text--lighten-1">4</span>',
subtitle: "<span class='text--primary'>to Alex, Scott, Jennifer</span> — Wish I could come, but I'm out of town this weekend.",
},
{ divider: true, inset: true },
{
avatar: 'https://cdn.vuetifyjs.com/images/lists/3.jpg',
title: 'Oui oui',
subtitle: "<span class='text--primary'>Sandra Adams</span> — Do you have Paris recommendations? Have you ever been?",
},
{ divider: true, inset: true },
{
avatar: 'https://cdn.vuetifyjs.com/images/lists/4.jpg',
title: 'Birthday gift',
subtitle: "<span class='text--primary'>Trevor Hansen</span> — Have any ideas about what we should get Heidi for her birthday?",
},
{ divider: true, inset: true },
{
avatar: 'https://cdn.vuetifyjs.com/images/lists/5.jpg',
title: 'Recipe to try',
subtitle: "<span class='text--primary'>Britta Holt</span> — We should eat this: Grate, Squash, Corn, and tomatillo Tacos.",
},
],
}),
}
</script>
Vue School
Learn Vue.js and modern and cutting-edge front-end technologies with our premium tutorials and video courses.
ads by Vuetify
](https://vueschool.io/?ref=vuetifyjs.com&friend=vuetify)
头像和列表项标题操作的组合
当使用一个 lists 插槽时,你必须手动定义它是否包含列表组标题(headers)或者列表项是否包含 avatar,这样做是为了确保正确的间距。
template script
<template>
<v-card
max-width="500"
class="mx-auto"
>
<v-toolbar
color="deep-purple accent-4"
dark
>
<v-app-bar-nav-icon></v-app-bar-nav-icon>
<v-toolbar-title>New Chat</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn icon>
<v-icon>mdi-magnify</v-icon>
</v-btn>
</v-toolbar>
<v-list subheader>
<v-subheader>Recent chat</v-subheader>
<v-list-item
v-for="item in items"
:key="item.title"
@click=""
>
<v-list-item-avatar>
<v-img :src="item.avatar"></v-img>
</v-list-item-avatar>
<v-list-item-content>
<v-list-item-title v-text="item.title"></v-list-item-title>
</v-list-item-content>
<v-list-item-icon>
<v-icon :color="item.active ? 'deep-purple accent-4' : 'grey'">chat_bubble</v-icon>
</v-list-item-icon>
</v-list-item>
</v-list>
<v-divider></v-divider>
<v-list subheader>
<v-subheader>Previous chats</v-subheader>
<v-list-item
v-for="item in items2"
:key="item.title"
@click=""
>
<v-list-item-avatar>
<v-img :src="item.avatar"></v-img>
</v-list-item-avatar>
<v-list-item-content>
<v-list-item-title v-text="item.title"></v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
</v-card>
</template>
<script>
export default {
data: () => ({
items: [
{ active: true, title: 'Jason Oner', avatar: 'https://cdn.vuetifyjs.com/images/lists/1.jpg' },
{ active: true, title: 'Ranee Carlson', avatar: 'https://cdn.vuetifyjs.com/images/lists/2.jpg' },
{ title: 'Cindy Baker', avatar: 'https://cdn.vuetifyjs.com/images/lists/3.jpg' },
{ title: 'Ali Connors', avatar: 'https://cdn.vuetifyjs.com/images/lists/4.jpg' },
],
items2: [
{ title: 'Travis Howard', avatar: 'https://cdn.vuetifyjs.com/images/lists/5.jpg' },
],
}),
}
</script>
嵌套列表
使用 v-list-group
组件,您可以使用 sub-group 属性创建多达 2 级的深度。
template script
<template>
<v-card
class="mx-auto"
width="300"
>
<v-list>
<v-list-item>
<v-list-item-icon>
<v-icon>mdi-home</v-icon>
</v-list-item-icon>
<v-list-item-title>Home</v-list-item-title>
</v-list-item>
<v-list-group
prepend-icon="account_circle"
value="true"
>
<template v-slot:activator>
<v-list-item-title>Users</v-list-item-title>
</template>
<v-list-group
no-action
sub-group
value="true"
>
<template v-slot:activator>
<v-list-item-content>
<v-list-item-title>Admin</v-list-item-title>
</v-list-item-content>
</template>
<v-list-item
v-for="(admin, i) in admins"
:key="i"
link
>
<v-list-item-title v-text="admin[0]"></v-list-item-title>
<v-list-item-icon>
<v-icon v-text="admin[1]"></v-icon>
</v-list-item-icon>
</v-list-item>
</v-list-group>
<v-list-group
sub-group
no-action
>
<template v-slot:activator>
<v-list-item-content>
<v-list-item-title>Actions</v-list-item-title>
</v-list-item-content>
</template>
<v-list-item
v-for="(crud, i) in cruds"
:key="i"
@click=""
>
<v-list-item-title v-text="crud[0]"></v-list-item-title>
<v-list-item-action>
<v-icon v-text="crud[1]"></v-icon>
</v-list-item-action>
</v-list-item>
</v-list-group>
</v-list-group>
</v-list>
</v-card>
</template>
<script>
export default {
data: () => ({
admins: [
['Management', 'people_outline'],
['Settings', 'settings'],
],
cruds: [
['Create', 'add'],
['Read', 'insert_drive_file'],
['Update', 'update'],
['Delete', 'delete'],
],
}),
}
</script>
列表组标题和分割线
Lists 组件可以包含多个列表组标题和分割线。
template script
<template>
<v-card
max-width="475"
class="mx-auto"
>
<v-toolbar
color="teal"
dark
>
<v-app-bar-nav-icon></v-app-bar-nav-icon>
<v-toolbar-title>Settings</v-toolbar-title>
</v-toolbar>
<v-list two-line subheader>
<v-subheader>General</v-subheader>
<v-list-item>
<v-list-item-content>
<v-list-item-title>Profile photo</v-list-item-title>
<v-list-item-subtitle>Change your Google+ profile photo</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
<v-list-item>
<v-list-item-content>
<v-list-item-title>Show your status</v-list-item-title>
<v-list-item-subtitle>Your status is visible to everyone</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
</v-list>
<v-divider></v-divider>
<v-list
subheader
two-line
flat
>
<v-subheader>Hangout notifications</v-subheader>
<v-list-item-group
v-model="settings"
multiple
>
<v-list-item>
<template v-slot:default="{ active, toggle }">
<v-list-item-action>
<v-checkbox
v-model="active"
color="primary"
@click="toggle"
></v-checkbox>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>Notifications</v-list-item-title>
<v-list-item-subtitle>Allow notifications</v-list-item-subtitle>
</v-list-item-content>
</template>
</v-list-item>
<v-list-item>
<template v-slot:default="{ active, toggle }">
<v-list-item-action>
<v-checkbox
v-model="active"
color="primary"
@click="toggle"
></v-checkbox>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>Sound</v-list-item-title>
<v-list-item-subtitle>Hangouts message</v-list-item-subtitle>
</v-list-item-content>
</template>
</v-list-item>
<v-list-item>
<template v-slot:default="{ active, toggle }">
<v-list-item-action>
<v-checkbox
v-model="active"
color="primary"
@click="toggle"
></v-checkbox>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>Video sounds</v-list-item-title>
<v-list-item-subtitle>Hangouts video call</v-list-item-subtitle>
</v-list-item-content>
</template>
</v-list-item>
<v-list-item>
<template v-slot:default="{ active, toggle }">
<v-list-item-action>
<v-checkbox
v-model="active"
color="primary"
@click="toggle"
></v-checkbox>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>Invites</v-list-item-title>
<v-list-item-subtitle>Notify when receiving invites</v-list-item-subtitle>
</v-list-item-content>
</template>
</v-list-item>
</v-list-item-group>
</v-list>
</v-card>
</template>
<script>
export default {
data: () => ({
settings: [],
}),
}
</script>
图像卡片和工具栏以及列表的组合
一个列表可以和卡片组合。
template
<template>
<v-card
max-width="375"
class="mx-auto"
>
<v-img
src="https://cdn.vuetifyjs.com/images/lists/ali.png"
height="300px"
dark
>
<v-row class="fill-height">
<v-card-title>
<v-btn dark icon>
<v-icon>mdi-chevron-left</v-icon>
</v-btn>
<v-spacer></v-spacer>
<v-btn dark icon class="mr-4">
<v-icon>mdi-pencil</v-icon>
</v-btn>
<v-btn dark icon>
<v-icon>mdi-dots-vertical</v-icon>
</v-btn>
</v-card-title>
<v-spacer></v-spacer>
<v-card-title class="white--text pl-12 pt-12">
<div class="display-1 pl-12 pt-12">Ali Conners</div>
</v-card-title>
</v-row>
</v-img>
<v-list two-line>
<v-list-item @click="">
<v-list-item-icon>
<v-icon color="indigo">mdi-phone</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>(650) 555-1234</v-list-item-title>
<v-list-item-subtitle>Mobile</v-list-item-subtitle>
</v-list-item-content>
<v-list-item-icon>
<v-icon>mdi-message-text</v-icon>
</v-list-item-icon>
</v-list-item>
<v-list-item @click="">
<v-list-item-action></v-list-item-action>
<v-list-item-content>
<v-list-item-title>(323) 555-6789</v-list-item-title>
<v-list-item-subtitle>Work</v-list-item-subtitle>
</v-list-item-content>
<v-list-item-icon>
<v-icon>mdi-message-text</v-icon>
</v-list-item-icon>
</v-list-item>
<v-divider inset></v-divider>
<v-list-item @click="">
<v-list-item-icon>
<v-icon color="indigo">mdi-email</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>aliconnors@example.com</v-list-item-title>
<v-list-item-subtitle>Personal</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
<v-list-item @click="">
<v-list-item-action></v-list-item-action>
<v-list-item-content>
<v-list-item-title>ali_connors@example.com</v-list-item-title>
<v-list-item-subtitle>Work</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
<v-divider inset></v-divider>
<v-list-item @click="">
<v-list-item-icon>
<v-icon color="indigo">mdi-map-marker</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>1400 Main Street</v-list-item-title>
<v-list-item-subtitle>Orlando, FL 79938</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
</v-list>
</v-card>
</template>
列表项的标题和子标题, 操作与操作文本说明
列表组件可以包含一个操作栈。波纹效果和路由属性也可以应用到 v-list 甚至 v-list-item中,或者作为列表项数组的一个属性。
template script
<template>
<v-card
max-width="500"
class="mx-auto"
>
<v-toolbar
color="pink"
dark
>
<v-app-bar-nav-icon></v-app-bar-nav-icon>
<v-toolbar-title>Inbox</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn icon>
<v-icon>mdi-magnify</v-icon>
</v-btn>
<v-btn icon>
<v-icon>mdi-checkbox-marked-circle</v-icon>
</v-btn>
</v-toolbar>
<v-list two-line>
<v-list-item-group
v-model="selected"
multiple
active-class="pink--text"
>
<template v-for="(item, index) in items">
<v-list-item :key="item.title">
<template v-slot:default="{ active, toggle }">
<v-list-item-content>
<v-list-item-title v-text="item.title"></v-list-item-title>
<v-list-item-subtitle class="text--primary" v-text="item.headline"></v-list-item-subtitle>
<v-list-item-subtitle v-text="item.subtitle"></v-list-item-subtitle>
</v-list-item-content>
<v-list-item-action>
<v-list-item-action-text v-text="item.action"></v-list-item-action-text>
<v-icon
v-if="!active"
color="grey lighten-1"
>
star_border
</v-icon>
<v-icon
v-else
color="yellow"
>
star
</v-icon>
</v-list-item-action>
</template>
</v-list-item>
<v-divider
v-if="index + 1 < items.length"
:key="index"
></v-divider>
</template>
</v-list-item-group>
</v-list>
</v-card>
</template>
<script>
export default {
data: () => ({
selected: [2],
items: [
{
action: '15 min',
headline: 'Brunch this weekend?',
title: 'Ali Connors',
subtitle: "I'll be in your neighborhood doing errands this weekend. Do you want to hang out?",
},
{
action: '2 hr',
headline: 'Summer BBQ',
title: 'me, Scrott, Jennifer',
subtitle: "Wish I could come, but I'm out of town this weekend.",
},
{
action: '6 hr',
headline: 'Oui oui',
title: 'Sandra Adams',
subtitle: 'Do you have Paris recommendations? Have you ever been?',
},
{
action: '12 hr',
headline: 'Birthday gift',
title: 'Trevor Hansen',
subtitle: 'Have any ideas about what we should get Heidi for her birthday?',
},
{
action: '18hr',
headline: 'Recipe to try',
title: 'Britta Holt',
subtitle: 'We should eat this: Grate, Squash, Corn, and tomatillo Tacos.',
},
],
}),
}
</script>
操作和标题以及副标题的组合
可操作的 three-line 列表。 利用 v-list-item-group,轻松将动作连接到图块。
template script
<template>
<v-card
class="mx-auto"
max-width="400"
>
<v-toolbar
color="purple"
dark
>
<v-app-bar-nav-icon></v-app-bar-nav-icon>
<v-toolbar-title>Settings</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn icon>
<v-icon>mdi-magnify</v-icon>
</v-btn>
</v-toolbar>
<v-list
subheader
three-line
>
<v-subheader>User Controls</v-subheader>
<v-list-item>
<v-list-item-content>
<v-list-item-title>Content filtering</v-list-item-title>
<v-list-item-subtitle>Set the content filtering level to restrict appts that can be downloaded</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
<v-list-item>
<v-list-item-content>
<v-list-item-title>Password</v-list-item-title>
<v-list-item-subtitle>Require password for purchase or use password to restrict purchase</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
</v-list>
<v-divider></v-divider>
<v-list
flat
subheader
three-line
>
<v-subheader>General</v-subheader>
<v-list-item-group
v-model="settings"
multiple
active-class=""
>
<v-list-item>
<template v-slot:default="{ active }">
<v-list-item-action>
<v-checkbox v-model="active"></v-checkbox>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>Notifications</v-list-item-title>
<v-list-item-subtitle>Notify me about updates to apps or games that I downloaded</v-list-item-subtitle>
</v-list-item-content>
</template>
</v-list-item>
<v-list-item>
<template v-slot:default="{ active }">
<v-list-item-action>
<v-checkbox v-model="active"></v-checkbox>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>Sound</v-list-item-title>
<v-list-item-subtitle>Auto-update apps at any time. Data charges may apply</v-list-item-subtitle>
</v-list-item-content>
</template>
</v-list-item>
<v-list-item>
<template v-slot:default="{ active }">
<v-list-item-action>
<v-checkbox v-model="active"></v-checkbox>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>Auto-add widgets</v-list-item-title>
<v-list-item-subtitle>Automatically add home screen widgets when downloads complete</v-list-item-subtitle>
</v-list-item-content>
</template>
</v-list-item>
</v-list-item-group>
</v-list>
</v-card>
</template>
<script>
export default {
data () {
return {
settings: [],
}
},
}
</script>
可展开的列表
列表可以包含一组项目,这些项目将在单击时显示。 扩展列表也用于 v-navigation-drawer 组件中。
template script
<template>
<v-card
max-width="500"
class="mx-auto"
>
<v-toolbar
color="teal"
dark
>
<v-app-bar-nav-icon></v-app-bar-nav-icon>
<v-toolbar-title>Topics</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn icon>
<v-icon>mdi-dots-vertical</v-icon>
</v-btn>
</v-toolbar>
<v-list>
<v-list-group
v-for="item in items"
:key="item.title"
v-model="item.active"
:prepend-icon="item.action"
no-action
>
<template v-slot:activator>
<v-list-item-content>
<v-list-item-title v-text="item.title"></v-list-item-title>
</v-list-item-content>
</template>
<v-list-item
v-for="subItem in item.items"
:key="subItem.title"
@click=""
>
<v-list-item-content>
<v-list-item-title v-text="subItem.title"></v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list-group>
</v-list>
</v-card>
</template>
<script>
export default {
data () {
return {
items: [
{
action: 'local_activity',
title: 'Attractions',
items: [
{ title: 'List Item' },
],
},
{
action: 'restaurant',
title: 'Dining',
active: true,
items: [
{ title: 'Breakfast & brunch' },
{ title: 'New American' },
{ title: 'Sushi' },
],
},
{
action: 'school',
title: 'Education',
items: [
{ title: 'List Item' },
],
},
{
action: 'directions_run',
title: 'Family',
items: [
{ title: 'List Item' },
],
},
{
action: 'healing',
title: 'Health',
items: [
{ title: 'List Item' },
],
},
{
action: 'content_cut',
title: 'Office',
items: [
{ title: 'List Item' },
],
},
{
action: 'local_offer',
title: 'Promotions',
items: [
{ title: 'List Item' },
],
},
],
}
},
}
</script>
导航列表
列表可以接受一个替代的 nav 样式,它减少了 v-list-item
的宽度,并增加了一个边框半径。
template script
<template>
<v-card
class="mx-auto"
width="256"
tile
>
<v-navigation-drawer permanent>
<v-system-bar></v-system-bar>
<v-list>
<v-list-item>
<v-list-item-avatar>
<v-img src="https://cdn.vuetifyjs.com/images/john.png"></v-img>
</v-list-item-avatar>
</v-list-item>
<v-list-item link>
<v-list-item-content>
<v-list-item-title class="title">John Leider</v-list-item-title>
<v-list-item-subtitle>john@vuetifyjs.com</v-list-item-subtitle>
</v-list-item-content>
<v-list-item-action>
<v-icon>mdi-menu-down</v-icon>
</v-list-item-action>
</v-list-item>
</v-list>
<v-divider></v-divider>
<v-list
nav
dense
>
<v-list-item-group v-model="item" color="primary">
<v-list-item
v-for="(item, i) in items"
:key="i"
>
<v-list-item-icon>
<v-icon v-text="item.icon"></v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title v-text="item.text"></v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list-item-group>
</v-list>
</v-navigation-drawer>
</v-card>
</template>
<script>
export default {
data: () => ({
item: 0,
items: [
{ text: 'My Files', icon: 'mdi-folder' },
{ text: 'Shared with me', icon: 'mdi-account-multiple' },
{ text: 'Starred', icon: 'mdi-star' },
{ text: 'Recent', icon: 'mdi-history' },
{ text: 'Offline', icon: 'mdi-check-circle' },
{ text: 'Uploads', icon: 'mdi-upload' },
{ text: 'Backups', icon: 'mdi-cloud-upload' },
],
}),
}
</script>