列表

v-list 组件用于显示信息,它可以包含一个头像、内容、操作、列表组标题等等。列表也可以包含子元素并在侧边栏(sidebar)使用。

如果您要查找有状态列表项,请查看 v-list-item-group

用例

列表有三个主要变量。single-line (默认), two-linethree-line。 行声明指定了项目的最小高度,也可以使用相同的属性从 v-list 中进行控制。

template


  1. <template>
  2. <v-card
  3. class="mx-auto"
  4. max-width="400"
  5. tile
  6. >
  7. <v-list-item>
  8. <v-list-item-content>
  9. <v-list-item-title>Single-line item</v-list-item-title>
  10. </v-list-item-content>
  11. </v-list-item>
  12. <v-list-item two-line>
  13. <v-list-item-content>
  14. <v-list-item-title>Two-line item</v-list-item-title>
  15. <v-list-item-subtitle>Secondary text</v-list-item-subtitle>
  16. </v-list-item-content>
  17. </v-list-item>
  18. <v-list-item three-line>
  19. <v-list-item-content>
  20. <v-list-item-title>Three-line item</v-list-item-title>
  21. <v-list-item-subtitle>
  22. Secondary line text Lorem ipsum dolor sit amet,
  23. </v-list-item-subtitle>
  24. <v-list-item-subtitle>
  25. consectetur adipiscing elit.
  26. </v-list-item-subtitle>
  27. </v-list-item-content>
  28. </v-list-item>
  29. </v-card>
  30. </template>

Lists(列表) - 图1

API

从下面选择您想要的组件,并查看可用的属性、插槽、事件和函数。

Lists(列表) - 图2

实战场

template script


  1. <template>
  2. <v-row align="center">
  3. <v-row justify="space-around">
  4. <v-switch v-model="disabled" class="ma-2" label="Disabled"></v-switch>
  5. <v-switch v-model="dense" class="ma-2" label="Dense"></v-switch>
  6. <v-switch v-model="twoLine" class="ma-2" label="Two-line"></v-switch>
  7. <v-switch v-model="threeLine" class="ma-2" label="Three-line"></v-switch>
  8. <v-switch v-model="shaped" class="ma-2" label="Shaped"></v-switch>
  9. <v-switch v-model="flat" class="ma-2" label="Flat"></v-switch>
  10. <v-switch v-model="subheader" class="ma-2" label="Subheader"></v-switch>
  11. <v-switch v-model="inactive" class="ma-2" label="Inactive"></v-switch>
  12. <v-switch v-model="subGroup" class="ma-2" label="Sub-group"></v-switch>
  13. <v-switch v-model="nav" class="ma-2" label="Nav"></v-switch>
  14. <v-switch v-model="avatar" class="ma-2" label="Avatar"></v-switch>
  15. <v-switch v-model="rounded" class="ma-2" label="Rounded"></v-switch>
  16. </v-row>
  17. <v-card
  18. class="mx-auto"
  19. max-width="400"
  20. tile
  21. >
  22. <v-list
  23. :disabled="disabled"
  24. :dense="dense"
  25. :two-line="twoLine"
  26. :three-line="threeLine"
  27. :shaped="shaped"
  28. :flat="flat"
  29. :subheader="subheader"
  30. :sub-group="subGroup"
  31. :nav="nav"
  32. :avatar="avatar"
  33. :rounded="rounded"
  34. >
  35. <v-subheader>REPORTS</v-subheader>
  36. <v-list-item-group v-model="item" color="primary">
  37. <v-list-item
  38. v-for="(item, i) in items"
  39. :key="i"
  40. :inactive="inactive"
  41. >
  42. <v-list-item-avatar v-if="avatar">
  43. <v-img :src="item.avatar"></v-img>
  44. </v-list-item-avatar>
  45. <v-list-item-content>
  46. <v-list-item-title v-html="item.title"></v-list-item-title>
  47. <v-list-item-subtitle v-if="twoLine || threeLine" v-html="item.subtitle"></v-list-item-subtitle>
  48. </v-list-item-content>
  49. </v-list-item>
  50. </v-list-item-group>
  51. </v-list>
  52. </v-card>
  53. </v-row>
  54. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. item: 5,
  5. items: [
  6. {
  7. avatar: 'https://cdn.vuetifyjs.com/images/lists/1.jpg',
  8. title: 'Brunch this weekend?',
  9. subtitle: "<span class='text--primary'>Ali Connors</span> &mdash; I'll be in your neighborhood doing errands this weekend. Do you want to hang out?",
  10. },
  11. {
  12. avatar: 'https://cdn.vuetifyjs.com/images/lists/2.jpg',
  13. title: 'Summer BBQ <span class="grey--text text--lighten-1">4</span>',
  14. subtitle: "<span class='text--primary'>to Alex, Scott, Jennifer</span> &mdash; Wish I could come, but I'm out of town this weekend.",
  15. },
  16. {
  17. avatar: 'https://cdn.vuetifyjs.com/images/lists/3.jpg',
  18. title: 'Oui oui',
  19. subtitle: "<span class='text--primary'>Sandra Adams</span> &mdash; Do you have Paris recommendations? Have you ever been?",
  20. },
  21. {
  22. avatar: 'https://cdn.vuetifyjs.com/images/lists/4.jpg',
  23. title: 'Birthday gift',
  24. subtitle: "<span class='text--primary'>Trevor Hansen</span> &mdash; Have any ideas about what we should get Heidi for her birthday?",
  25. },
  26. {
  27. avatar: 'https://cdn.vuetifyjs.com/images/lists/5.jpg',
  28. title: 'Recipe to try',
  29. subtitle: "<span class='text--primary'>Britta Holt</span> &mdash; We should eat this: Grate, Squash, Corn, and tomatillo Tacos.",
  30. },
  31. ],
  32. disabled: false,
  33. dense: false,
  34. twoLine: false,
  35. threeLine: false,
  36. shaped: false,
  37. flat: false,
  38. subheader: false,
  39. inactive: false,
  40. subGroup: false,
  41. nav: false,
  42. avatar: false,
  43. rounded: false,
  44. }),
  45. }
  46. </script>

Lists(列表) - 图3

示例

下面是一些简单到复杂的例子。

已禁用列表

您不能与禁用的 v-list 互动。

template script


  1. <template>
  2. <v-card
  3. class="mx-auto"
  4. max-width="300"
  5. tile
  6. >
  7. <v-list disabled>
  8. <v-subheader>REPORTS</v-subheader>
  9. <v-list-item-group v-model="item" color="primary">
  10. <v-list-item
  11. v-for="(item, i) in items"
  12. :key="i"
  13. >
  14. <v-list-item-icon>
  15. <v-icon v-text="item.icon"></v-icon>
  16. </v-list-item-icon>
  17. <v-list-item-content>
  18. <v-list-item-title v-text="item.text"></v-list-item-title>
  19. </v-list-item-content>
  20. </v-list-item>
  21. </v-list-item-group>
  22. </v-list>
  23. </v-card>
  24. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. item: 1,
  5. items: [
  6. { text: 'Real-Time', icon: 'mdi-clock' },
  7. { text: 'Audience', icon: 'mdi-account' },
  8. { text: 'Conversions', icon: 'mdi-flag' },
  9. ],
  10. }),
  11. }
  12. </script>

Lists(列表) - 图4

形状列表

形状列表在 v-list-item 的一侧具有圆形边界。

template script


  1. <template>
  2. <v-card
  3. class="mx-auto"
  4. max-width="300"
  5. tile
  6. >
  7. <v-list shaped>
  8. <v-subheader>REPORTS</v-subheader>
  9. <v-list-item-group v-model="item" color="primary">
  10. <v-list-item
  11. v-for="(item, i) in items"
  12. :key="i"
  13. >
  14. <v-list-item-icon>
  15. <v-icon v-text="item.icon"></v-icon>
  16. </v-list-item-icon>
  17. <v-list-item-content>
  18. <v-list-item-title v-text="item.text"></v-list-item-title>
  19. </v-list-item-content>
  20. </v-list-item>
  21. </v-list-item-group>
  22. </v-list>
  23. </v-card>
  24. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. item: 1,
  5. items: [
  6. { text: 'Real-Time', icon: 'mdi-clock' },
  7. { text: 'Audience', icon: 'mdi-account' },
  8. { text: 'Conversions', icon: 'mdi-flag' },
  9. ],
  10. }),
  11. }
  12. </script>

Lists(列表) - 图5

密集

v-list 可以通过 dense 属性变密集。

template script


  1. <template>
  2. <v-card
  3. class="mx-auto"
  4. max-width="300"
  5. tile
  6. >
  7. <v-list dense>
  8. <v-subheader>REPORTS</v-subheader>
  9. <v-list-item-group v-model="item" color="primary">
  10. <v-list-item
  11. v-for="(item, i) in items"
  12. :key="i"
  13. >
  14. <v-list-item-icon>
  15. <v-icon v-text="item.icon"></v-icon>
  16. </v-list-item-icon>
  17. <v-list-item-content>
  18. <v-list-item-title v-text="item.text"></v-list-item-title>
  19. </v-list-item-content>
  20. </v-list-item>
  21. </v-list-item-group>
  22. </v-list>
  23. </v-card>
  24. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. item: 1,
  5. items: [
  6. { text: 'Real-Time', icon: 'mdi-clock' },
  7. { text: 'Audience', icon: 'mdi-account' },
  8. { text: 'Conversions', icon: 'mdi-flag' },
  9. ],
  10. }),
  11. }
  12. </script>

Lists(列表) - 图6

扁平

flat 属性的 v-list 中选择时,项目不会发生变化。

template script


  1. <template>
  2. <v-card
  3. class="mx-auto"
  4. max-width="300"
  5. tile
  6. >
  7. <v-list flat>
  8. <v-subheader>REPORTS</v-subheader>
  9. <v-list-item-group v-model="item" color="primary">
  10. <v-list-item
  11. v-for="(item, i) in items"
  12. :key="i"
  13. >
  14. <v-list-item-icon>
  15. <v-icon v-text="item.icon"></v-icon>
  16. </v-list-item-icon>
  17. <v-list-item-content>
  18. <v-list-item-title v-text="item.text"></v-list-item-title>
  19. </v-list-item-content>
  20. </v-list-item>
  21. </v-list-item-group>
  22. </v-list>
  23. </v-card>
  24. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. item: 1,
  5. items: [
  6. { text: 'Real-Time', icon: 'mdi-clock' },
  7. { text: 'Audience', icon: 'mdi-account' },
  8. { text: 'Conversions', icon: 'mdi-flag' },
  9. ],
  10. }),
  11. }
  12. </script>

Lists(列表) - 图7

圆角

你可以让 v-list 项变成圆角。

template script


  1. <template>
  2. <v-card
  3. class="mx-auto"
  4. max-width="300"
  5. tile
  6. >
  7. <v-list rounded>
  8. <v-subheader>REPORTS</v-subheader>
  9. <v-list-item-group v-model="item" color="primary">
  10. <v-list-item
  11. v-for="(item, i) in items"
  12. :key="i"
  13. >
  14. <v-list-item-icon>
  15. <v-icon v-text="item.icon"></v-icon>
  16. </v-list-item-icon>
  17. <v-list-item-content>
  18. <v-list-item-title v-text="item.text"></v-list-item-title>
  19. </v-list-item-content>
  20. </v-list-item>
  21. </v-list-item-group>
  22. </v-list>
  23. </v-card>
  24. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. item: 1,
  5. items: [
  6. { text: 'Real-Time', icon: 'mdi-clock' },
  7. { text: 'Audience', icon: 'mdi-account' },
  8. { text: 'Conversions', icon: 'mdi-flag' },
  9. ],
  10. }),
  11. }
  12. </script>

Lists(列表) - 图8

头像和列表项标题操作的组合

列表中还包含有插槽,可以采用更明确的方法。如果你选择了这种方法,请记住你必须提供额外的 props,以获得正确的间距。在这个例子中,我们有一个带头像的标题,所以我们必须提供一个 avatar 属性。

template script


  1. <template>
  2. <v-card
  3. max-width="500"
  4. class="mx-auto"
  5. >
  6. <v-toolbar
  7. color="indigo"
  8. dark
  9. >
  10. <v-app-bar-nav-icon></v-app-bar-nav-icon>
  11. <v-toolbar-title>Inbox</v-toolbar-title>
  12. <v-spacer></v-spacer>
  13. <v-btn icon>
  14. <v-icon>mdi-magnify</v-icon>
  15. </v-btn>
  16. <v-btn icon>
  17. <v-icon>mdi-dots-vertical</v-icon>
  18. </v-btn>
  19. </v-toolbar>
  20. <v-list>
  21. <v-list-item
  22. v-for="item in items"
  23. :key="item.title"
  24. @click=""
  25. >
  26. <v-list-item-icon>
  27. <v-icon v-if="item.icon" color="pink">mdi-star</v-icon>
  28. </v-list-item-icon>
  29. <v-list-item-content>
  30. <v-list-item-title v-text="item.title"></v-list-item-title>
  31. </v-list-item-content>
  32. <v-list-item-avatar>
  33. <v-img :src="item.avatar"></v-img>
  34. </v-list-item-avatar>
  35. </v-list-item>
  36. </v-list>
  37. </v-card>
  38. </template>
  1. <script>
  2. export default {
  3. data () {
  4. return {
  5. items: [
  6. { icon: true, title: 'Jason Oner', avatar: 'https://cdn.vuetifyjs.com/images/lists/1.jpg' },
  7. { title: 'Travis Howard', avatar: 'https://cdn.vuetifyjs.com/images/lists/2.jpg' },
  8. { title: 'Ali Connors', avatar: 'https://cdn.vuetifyjs.com/images/lists/3.jpg' },
  9. { title: 'Cindy Baker', avatar: 'https://cdn.vuetifyjs.com/images/lists/4.jpg' },
  10. ],
  11. }
  12. },
  13. }
  14. </script>

Lists(列表) - 图9

具有两行内容加上图标的操作

列表组件可以包含列表组标题,分割线,以及1行或者更多行,如果副标题文本溢出则会以省略号的形式截断文本

template script


  1. <template>
  2. <v-card
  3. max-width="600"
  4. class="mx-auto"
  5. >
  6. <v-toolbar
  7. color="light-blue"
  8. dark
  9. >
  10. <v-app-bar-nav-icon></v-app-bar-nav-icon>
  11. <v-toolbar-title>My files</v-toolbar-title>
  12. <v-spacer></v-spacer>
  13. <v-btn icon>
  14. <v-icon>mdi-magnify</v-icon>
  15. </v-btn>
  16. <v-btn icon>
  17. <v-icon>mdi-view-module</v-icon>
  18. </v-btn>
  19. </v-toolbar>
  20. <v-list two-line subheader>
  21. <v-subheader inset>Folders</v-subheader>
  22. <v-list-item
  23. v-for="item in items"
  24. :key="item.title"
  25. @click=""
  26. >
  27. <v-list-item-avatar>
  28. <v-icon
  29. :class="[item.iconClass]"
  30. v-text="item.icon"
  31. ></v-icon>
  32. </v-list-item-avatar>
  33. <v-list-item-content>
  34. <v-list-item-title v-text="item.title"></v-list-item-title>
  35. <v-list-item-subtitle v-text="item.subtitle"></v-list-item-subtitle>
  36. </v-list-item-content>
  37. <v-list-item-action>
  38. <v-btn icon>
  39. <v-icon color="grey lighten-1">mdi-information</v-icon>
  40. </v-btn>
  41. </v-list-item-action>
  42. </v-list-item>
  43. <v-divider inset></v-divider>
  44. <v-subheader inset>Files</v-subheader>
  45. <v-list-item
  46. v-for="item in items2"
  47. :key="item.title"
  48. @click=""
  49. >
  50. <v-list-item-avatar>
  51. <v-icon
  52. :class="[item.iconClass]"
  53. v-text="item.icon"
  54. ></v-icon>
  55. </v-list-item-avatar>
  56. <v-list-item-content>
  57. <v-list-item-title v-text="item.title"></v-list-item-title>
  58. <v-list-item-subtitle v-text="item.subtitle"></v-list-item-subtitle>
  59. </v-list-item-content>
  60. <v-list-item-action>
  61. <v-btn icon>
  62. <v-icon color="grey lighten-1">mdi-information</v-icon>
  63. </v-btn>
  64. </v-list-item-action>
  65. </v-list-item>
  66. </v-list>
  67. </v-card>
  68. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. items: [
  5. { icon: 'folder', iconClass: 'grey lighten-1 white--text', title: 'Photos', subtitle: 'Jan 9, 2014' },
  6. { icon: 'folder', iconClass: 'grey lighten-1 white--text', title: 'Recipes', subtitle: 'Jan 17, 2014' },
  7. { icon: 'folder', iconClass: 'grey lighten-1 white--text', title: 'Work', subtitle: 'Jan 28, 2014' },
  8. ],
  9. items2: [
  10. { icon: 'assignment', iconClass: 'blue white--text', title: 'Vacation itinerary', subtitle: 'Jan 20, 2014' },
  11. { icon: 'call_to_action', iconClass: 'amber white--text', title: 'Kitchen remodel', subtitle: 'Jan 10, 2014' },
  12. ],
  13. }),
  14. }
  15. </script>

Lists(列表) - 图10

头像和三行内容的组合

对于三行列表,字幕将垂直夹在 2 行,然后省略。 此功能使用 line-clamp ,并不是所有浏览器都支持此功能。

template script


  1. <template>
  2. <v-card
  3. max-width="450"
  4. class="mx-auto"
  5. >
  6. <v-toolbar
  7. color="cyan"
  8. dark
  9. >
  10. <v-app-bar-nav-icon></v-app-bar-nav-icon>
  11. <v-toolbar-title>Inbox</v-toolbar-title>
  12. <v-spacer></v-spacer>
  13. <v-btn icon>
  14. <v-icon>mdi-magnify</v-icon>
  15. </v-btn>
  16. </v-toolbar>
  17. <v-list three-line>
  18. <template v-for="(item, index) in items">
  19. <v-subheader
  20. v-if="item.header"
  21. :key="item.header"
  22. v-text="item.header"
  23. ></v-subheader>
  24. <v-divider
  25. v-else-if="item.divider"
  26. :key="index"
  27. :inset="item.inset"
  28. ></v-divider>
  29. <v-list-item
  30. v-else
  31. :key="item.title"
  32. @click=""
  33. >
  34. <v-list-item-avatar>
  35. <v-img :src="item.avatar"></v-img>
  36. </v-list-item-avatar>
  37. <v-list-item-content>
  38. <v-list-item-title v-html="item.title"></v-list-item-title>
  39. <v-list-item-subtitle v-html="item.subtitle"></v-list-item-subtitle>
  40. </v-list-item-content>
  41. </v-list-item>
  42. </template>
  43. </v-list>
  44. </v-card>
  45. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. items: [
  5. { header: 'Today' },
  6. {
  7. avatar: 'https://cdn.vuetifyjs.com/images/lists/1.jpg',
  8. title: 'Brunch this weekend?',
  9. subtitle: "<span class='text--primary'>Ali Connors</span> &mdash; I'll be in your neighborhood doing errands this weekend. Do you want to hang out?",
  10. },
  11. { divider: true, inset: true },
  12. {
  13. avatar: 'https://cdn.vuetifyjs.com/images/lists/2.jpg',
  14. title: 'Summer BBQ <span class="grey--text text--lighten-1">4</span>',
  15. subtitle: "<span class='text--primary'>to Alex, Scott, Jennifer</span> &mdash; Wish I could come, but I'm out of town this weekend.",
  16. },
  17. { divider: true, inset: true },
  18. {
  19. avatar: 'https://cdn.vuetifyjs.com/images/lists/3.jpg',
  20. title: 'Oui oui',
  21. subtitle: "<span class='text--primary'>Sandra Adams</span> &mdash; Do you have Paris recommendations? Have you ever been?",
  22. },
  23. { divider: true, inset: true },
  24. {
  25. avatar: 'https://cdn.vuetifyjs.com/images/lists/4.jpg',
  26. title: 'Birthday gift',
  27. subtitle: "<span class='text--primary'>Trevor Hansen</span> &mdash; Have any ideas about what we should get Heidi for her birthday?",
  28. },
  29. { divider: true, inset: true },
  30. {
  31. avatar: 'https://cdn.vuetifyjs.com/images/lists/5.jpg',
  32. title: 'Recipe to try',
  33. subtitle: "<span class='text--primary'>Britta Holt</span> &mdash; We should eat this: Grate, Squash, Corn, and tomatillo Tacos.",
  34. },
  35. ],
  36. }),
  37. }
  38. </script>

Lists(列表) - 图11

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


  1. <template>
  2. <v-card
  3. max-width="500"
  4. class="mx-auto"
  5. >
  6. <v-toolbar
  7. color="deep-purple accent-4"
  8. dark
  9. >
  10. <v-app-bar-nav-icon></v-app-bar-nav-icon>
  11. <v-toolbar-title>New Chat</v-toolbar-title>
  12. <v-spacer></v-spacer>
  13. <v-btn icon>
  14. <v-icon>mdi-magnify</v-icon>
  15. </v-btn>
  16. </v-toolbar>
  17. <v-list subheader>
  18. <v-subheader>Recent chat</v-subheader>
  19. <v-list-item
  20. v-for="item in items"
  21. :key="item.title"
  22. @click=""
  23. >
  24. <v-list-item-avatar>
  25. <v-img :src="item.avatar"></v-img>
  26. </v-list-item-avatar>
  27. <v-list-item-content>
  28. <v-list-item-title v-text="item.title"></v-list-item-title>
  29. </v-list-item-content>
  30. <v-list-item-icon>
  31. <v-icon :color="item.active ? 'deep-purple accent-4' : 'grey'">chat_bubble</v-icon>
  32. </v-list-item-icon>
  33. </v-list-item>
  34. </v-list>
  35. <v-divider></v-divider>
  36. <v-list subheader>
  37. <v-subheader>Previous chats</v-subheader>
  38. <v-list-item
  39. v-for="item in items2"
  40. :key="item.title"
  41. @click=""
  42. >
  43. <v-list-item-avatar>
  44. <v-img :src="item.avatar"></v-img>
  45. </v-list-item-avatar>
  46. <v-list-item-content>
  47. <v-list-item-title v-text="item.title"></v-list-item-title>
  48. </v-list-item-content>
  49. </v-list-item>
  50. </v-list>
  51. </v-card>
  52. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. items: [
  5. { active: true, title: 'Jason Oner', avatar: 'https://cdn.vuetifyjs.com/images/lists/1.jpg' },
  6. { active: true, title: 'Ranee Carlson', avatar: 'https://cdn.vuetifyjs.com/images/lists/2.jpg' },
  7. { title: 'Cindy Baker', avatar: 'https://cdn.vuetifyjs.com/images/lists/3.jpg' },
  8. { title: 'Ali Connors', avatar: 'https://cdn.vuetifyjs.com/images/lists/4.jpg' },
  9. ],
  10. items2: [
  11. { title: 'Travis Howard', avatar: 'https://cdn.vuetifyjs.com/images/lists/5.jpg' },
  12. ],
  13. }),
  14. }
  15. </script>

Lists(列表) - 图12

嵌套列表

使用 v-list-group 组件,您可以使用 sub-group 属性创建多达 2 级的深度。

template script


  1. <template>
  2. <v-card
  3. class="mx-auto"
  4. width="300"
  5. >
  6. <v-list>
  7. <v-list-item>
  8. <v-list-item-icon>
  9. <v-icon>mdi-home</v-icon>
  10. </v-list-item-icon>
  11. <v-list-item-title>Home</v-list-item-title>
  12. </v-list-item>
  13. <v-list-group
  14. prepend-icon="account_circle"
  15. value="true"
  16. >
  17. <template v-slot:activator>
  18. <v-list-item-title>Users</v-list-item-title>
  19. </template>
  20. <v-list-group
  21. no-action
  22. sub-group
  23. value="true"
  24. >
  25. <template v-slot:activator>
  26. <v-list-item-content>
  27. <v-list-item-title>Admin</v-list-item-title>
  28. </v-list-item-content>
  29. </template>
  30. <v-list-item
  31. v-for="(admin, i) in admins"
  32. :key="i"
  33. link
  34. >
  35. <v-list-item-title v-text="admin[0]"></v-list-item-title>
  36. <v-list-item-icon>
  37. <v-icon v-text="admin[1]"></v-icon>
  38. </v-list-item-icon>
  39. </v-list-item>
  40. </v-list-group>
  41. <v-list-group
  42. sub-group
  43. no-action
  44. >
  45. <template v-slot:activator>
  46. <v-list-item-content>
  47. <v-list-item-title>Actions</v-list-item-title>
  48. </v-list-item-content>
  49. </template>
  50. <v-list-item
  51. v-for="(crud, i) in cruds"
  52. :key="i"
  53. @click=""
  54. >
  55. <v-list-item-title v-text="crud[0]"></v-list-item-title>
  56. <v-list-item-action>
  57. <v-icon v-text="crud[1]"></v-icon>
  58. </v-list-item-action>
  59. </v-list-item>
  60. </v-list-group>
  61. </v-list-group>
  62. </v-list>
  63. </v-card>
  64. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. admins: [
  5. ['Management', 'people_outline'],
  6. ['Settings', 'settings'],
  7. ],
  8. cruds: [
  9. ['Create', 'add'],
  10. ['Read', 'insert_drive_file'],
  11. ['Update', 'update'],
  12. ['Delete', 'delete'],
  13. ],
  14. }),
  15. }
  16. </script>

Lists(列表) - 图13

列表组标题和分割线

Lists 组件可以包含多个列表组标题和分割线。

template script


  1. <template>
  2. <v-card
  3. max-width="475"
  4. class="mx-auto"
  5. >
  6. <v-toolbar
  7. color="teal"
  8. dark
  9. >
  10. <v-app-bar-nav-icon></v-app-bar-nav-icon>
  11. <v-toolbar-title>Settings</v-toolbar-title>
  12. </v-toolbar>
  13. <v-list two-line subheader>
  14. <v-subheader>General</v-subheader>
  15. <v-list-item>
  16. <v-list-item-content>
  17. <v-list-item-title>Profile photo</v-list-item-title>
  18. <v-list-item-subtitle>Change your Google+ profile photo</v-list-item-subtitle>
  19. </v-list-item-content>
  20. </v-list-item>
  21. <v-list-item>
  22. <v-list-item-content>
  23. <v-list-item-title>Show your status</v-list-item-title>
  24. <v-list-item-subtitle>Your status is visible to everyone</v-list-item-subtitle>
  25. </v-list-item-content>
  26. </v-list-item>
  27. </v-list>
  28. <v-divider></v-divider>
  29. <v-list
  30. subheader
  31. two-line
  32. flat
  33. >
  34. <v-subheader>Hangout notifications</v-subheader>
  35. <v-list-item-group
  36. v-model="settings"
  37. multiple
  38. >
  39. <v-list-item>
  40. <template v-slot:default="{ active, toggle }">
  41. <v-list-item-action>
  42. <v-checkbox
  43. v-model="active"
  44. color="primary"
  45. @click="toggle"
  46. ></v-checkbox>
  47. </v-list-item-action>
  48. <v-list-item-content>
  49. <v-list-item-title>Notifications</v-list-item-title>
  50. <v-list-item-subtitle>Allow notifications</v-list-item-subtitle>
  51. </v-list-item-content>
  52. </template>
  53. </v-list-item>
  54. <v-list-item>
  55. <template v-slot:default="{ active, toggle }">
  56. <v-list-item-action>
  57. <v-checkbox
  58. v-model="active"
  59. color="primary"
  60. @click="toggle"
  61. ></v-checkbox>
  62. </v-list-item-action>
  63. <v-list-item-content>
  64. <v-list-item-title>Sound</v-list-item-title>
  65. <v-list-item-subtitle>Hangouts message</v-list-item-subtitle>
  66. </v-list-item-content>
  67. </template>
  68. </v-list-item>
  69. <v-list-item>
  70. <template v-slot:default="{ active, toggle }">
  71. <v-list-item-action>
  72. <v-checkbox
  73. v-model="active"
  74. color="primary"
  75. @click="toggle"
  76. ></v-checkbox>
  77. </v-list-item-action>
  78. <v-list-item-content>
  79. <v-list-item-title>Video sounds</v-list-item-title>
  80. <v-list-item-subtitle>Hangouts video call</v-list-item-subtitle>
  81. </v-list-item-content>
  82. </template>
  83. </v-list-item>
  84. <v-list-item>
  85. <template v-slot:default="{ active, toggle }">
  86. <v-list-item-action>
  87. <v-checkbox
  88. v-model="active"
  89. color="primary"
  90. @click="toggle"
  91. ></v-checkbox>
  92. </v-list-item-action>
  93. <v-list-item-content>
  94. <v-list-item-title>Invites</v-list-item-title>
  95. <v-list-item-subtitle>Notify when receiving invites</v-list-item-subtitle>
  96. </v-list-item-content>
  97. </template>
  98. </v-list-item>
  99. </v-list-item-group>
  100. </v-list>
  101. </v-card>
  102. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. settings: [],
  5. }),
  6. }
  7. </script>

Lists(列表) - 图14

图像卡片和工具栏以及列表的组合

一个列表可以和卡片组合。

template


  1. <template>
  2. <v-card
  3. max-width="375"
  4. class="mx-auto"
  5. >
  6. <v-img
  7. src="https://cdn.vuetifyjs.com/images/lists/ali.png"
  8. height="300px"
  9. dark
  10. >
  11. <v-row class="fill-height">
  12. <v-card-title>
  13. <v-btn dark icon>
  14. <v-icon>mdi-chevron-left</v-icon>
  15. </v-btn>
  16. <v-spacer></v-spacer>
  17. <v-btn dark icon class="mr-4">
  18. <v-icon>mdi-pencil</v-icon>
  19. </v-btn>
  20. <v-btn dark icon>
  21. <v-icon>mdi-dots-vertical</v-icon>
  22. </v-btn>
  23. </v-card-title>
  24. <v-spacer></v-spacer>
  25. <v-card-title class="white--text pl-12 pt-12">
  26. <div class="display-1 pl-12 pt-12">Ali Conners</div>
  27. </v-card-title>
  28. </v-row>
  29. </v-img>
  30. <v-list two-line>
  31. <v-list-item @click="">
  32. <v-list-item-icon>
  33. <v-icon color="indigo">mdi-phone</v-icon>
  34. </v-list-item-icon>
  35. <v-list-item-content>
  36. <v-list-item-title>(650) 555-1234</v-list-item-title>
  37. <v-list-item-subtitle>Mobile</v-list-item-subtitle>
  38. </v-list-item-content>
  39. <v-list-item-icon>
  40. <v-icon>mdi-message-text</v-icon>
  41. </v-list-item-icon>
  42. </v-list-item>
  43. <v-list-item @click="">
  44. <v-list-item-action></v-list-item-action>
  45. <v-list-item-content>
  46. <v-list-item-title>(323) 555-6789</v-list-item-title>
  47. <v-list-item-subtitle>Work</v-list-item-subtitle>
  48. </v-list-item-content>
  49. <v-list-item-icon>
  50. <v-icon>mdi-message-text</v-icon>
  51. </v-list-item-icon>
  52. </v-list-item>
  53. <v-divider inset></v-divider>
  54. <v-list-item @click="">
  55. <v-list-item-icon>
  56. <v-icon color="indigo">mdi-email</v-icon>
  57. </v-list-item-icon>
  58. <v-list-item-content>
  59. <v-list-item-title>aliconnors@example.com</v-list-item-title>
  60. <v-list-item-subtitle>Personal</v-list-item-subtitle>
  61. </v-list-item-content>
  62. </v-list-item>
  63. <v-list-item @click="">
  64. <v-list-item-action></v-list-item-action>
  65. <v-list-item-content>
  66. <v-list-item-title>ali_connors@example.com</v-list-item-title>
  67. <v-list-item-subtitle>Work</v-list-item-subtitle>
  68. </v-list-item-content>
  69. </v-list-item>
  70. <v-divider inset></v-divider>
  71. <v-list-item @click="">
  72. <v-list-item-icon>
  73. <v-icon color="indigo">mdi-map-marker</v-icon>
  74. </v-list-item-icon>
  75. <v-list-item-content>
  76. <v-list-item-title>1400 Main Street</v-list-item-title>
  77. <v-list-item-subtitle>Orlando, FL 79938</v-list-item-subtitle>
  78. </v-list-item-content>
  79. </v-list-item>
  80. </v-list>
  81. </v-card>
  82. </template>

Lists(列表) - 图15

列表项的标题和子标题, 操作与操作文本说明

列表组件可以包含一个操作栈。波纹效果和路由属性也可以应用到 v-list 甚至 v-list-item中,或者作为列表项数组的一个属性。

template script


  1. <template>
  2. <v-card
  3. max-width="500"
  4. class="mx-auto"
  5. >
  6. <v-toolbar
  7. color="pink"
  8. dark
  9. >
  10. <v-app-bar-nav-icon></v-app-bar-nav-icon>
  11. <v-toolbar-title>Inbox</v-toolbar-title>
  12. <v-spacer></v-spacer>
  13. <v-btn icon>
  14. <v-icon>mdi-magnify</v-icon>
  15. </v-btn>
  16. <v-btn icon>
  17. <v-icon>mdi-checkbox-marked-circle</v-icon>
  18. </v-btn>
  19. </v-toolbar>
  20. <v-list two-line>
  21. <v-list-item-group
  22. v-model="selected"
  23. multiple
  24. active-class="pink--text"
  25. >
  26. <template v-for="(item, index) in items">
  27. <v-list-item :key="item.title">
  28. <template v-slot:default="{ active, toggle }">
  29. <v-list-item-content>
  30. <v-list-item-title v-text="item.title"></v-list-item-title>
  31. <v-list-item-subtitle class="text--primary" v-text="item.headline"></v-list-item-subtitle>
  32. <v-list-item-subtitle v-text="item.subtitle"></v-list-item-subtitle>
  33. </v-list-item-content>
  34. <v-list-item-action>
  35. <v-list-item-action-text v-text="item.action"></v-list-item-action-text>
  36. <v-icon
  37. v-if="!active"
  38. color="grey lighten-1"
  39. >
  40. star_border
  41. </v-icon>
  42. <v-icon
  43. v-else
  44. color="yellow"
  45. >
  46. star
  47. </v-icon>
  48. </v-list-item-action>
  49. </template>
  50. </v-list-item>
  51. <v-divider
  52. v-if="index + 1 < items.length"
  53. :key="index"
  54. ></v-divider>
  55. </template>
  56. </v-list-item-group>
  57. </v-list>
  58. </v-card>
  59. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. selected: [2],
  5. items: [
  6. {
  7. action: '15 min',
  8. headline: 'Brunch this weekend?',
  9. title: 'Ali Connors',
  10. subtitle: "I'll be in your neighborhood doing errands this weekend. Do you want to hang out?",
  11. },
  12. {
  13. action: '2 hr',
  14. headline: 'Summer BBQ',
  15. title: 'me, Scrott, Jennifer',
  16. subtitle: "Wish I could come, but I'm out of town this weekend.",
  17. },
  18. {
  19. action: '6 hr',
  20. headline: 'Oui oui',
  21. title: 'Sandra Adams',
  22. subtitle: 'Do you have Paris recommendations? Have you ever been?',
  23. },
  24. {
  25. action: '12 hr',
  26. headline: 'Birthday gift',
  27. title: 'Trevor Hansen',
  28. subtitle: 'Have any ideas about what we should get Heidi for her birthday?',
  29. },
  30. {
  31. action: '18hr',
  32. headline: 'Recipe to try',
  33. title: 'Britta Holt',
  34. subtitle: 'We should eat this: Grate, Squash, Corn, and tomatillo Tacos.',
  35. },
  36. ],
  37. }),
  38. }
  39. </script>

Lists(列表) - 图16

操作和标题以及副标题的组合

可操作的 three-line 列表。 利用 v-list-item-group,轻松将动作连接到图块。

template script


  1. <template>
  2. <v-card
  3. class="mx-auto"
  4. max-width="400"
  5. >
  6. <v-toolbar
  7. color="purple"
  8. dark
  9. >
  10. <v-app-bar-nav-icon></v-app-bar-nav-icon>
  11. <v-toolbar-title>Settings</v-toolbar-title>
  12. <v-spacer></v-spacer>
  13. <v-btn icon>
  14. <v-icon>mdi-magnify</v-icon>
  15. </v-btn>
  16. </v-toolbar>
  17. <v-list
  18. subheader
  19. three-line
  20. >
  21. <v-subheader>User Controls</v-subheader>
  22. <v-list-item>
  23. <v-list-item-content>
  24. <v-list-item-title>Content filtering</v-list-item-title>
  25. <v-list-item-subtitle>Set the content filtering level to restrict appts that can be downloaded</v-list-item-subtitle>
  26. </v-list-item-content>
  27. </v-list-item>
  28. <v-list-item>
  29. <v-list-item-content>
  30. <v-list-item-title>Password</v-list-item-title>
  31. <v-list-item-subtitle>Require password for purchase or use password to restrict purchase</v-list-item-subtitle>
  32. </v-list-item-content>
  33. </v-list-item>
  34. </v-list>
  35. <v-divider></v-divider>
  36. <v-list
  37. flat
  38. subheader
  39. three-line
  40. >
  41. <v-subheader>General</v-subheader>
  42. <v-list-item-group
  43. v-model="settings"
  44. multiple
  45. active-class=""
  46. >
  47. <v-list-item>
  48. <template v-slot:default="{ active }">
  49. <v-list-item-action>
  50. <v-checkbox v-model="active"></v-checkbox>
  51. </v-list-item-action>
  52. <v-list-item-content>
  53. <v-list-item-title>Notifications</v-list-item-title>
  54. <v-list-item-subtitle>Notify me about updates to apps or games that I downloaded</v-list-item-subtitle>
  55. </v-list-item-content>
  56. </template>
  57. </v-list-item>
  58. <v-list-item>
  59. <template v-slot:default="{ active }">
  60. <v-list-item-action>
  61. <v-checkbox v-model="active"></v-checkbox>
  62. </v-list-item-action>
  63. <v-list-item-content>
  64. <v-list-item-title>Sound</v-list-item-title>
  65. <v-list-item-subtitle>Auto-update apps at any time. Data charges may apply</v-list-item-subtitle>
  66. </v-list-item-content>
  67. </template>
  68. </v-list-item>
  69. <v-list-item>
  70. <template v-slot:default="{ active }">
  71. <v-list-item-action>
  72. <v-checkbox v-model="active"></v-checkbox>
  73. </v-list-item-action>
  74. <v-list-item-content>
  75. <v-list-item-title>Auto-add widgets</v-list-item-title>
  76. <v-list-item-subtitle>Automatically add home screen widgets when downloads complete</v-list-item-subtitle>
  77. </v-list-item-content>
  78. </template>
  79. </v-list-item>
  80. </v-list-item-group>
  81. </v-list>
  82. </v-card>
  83. </template>
  1. <script>
  2. export default {
  3. data () {
  4. return {
  5. settings: [],
  6. }
  7. },
  8. }
  9. </script>

Lists(列表) - 图17

可展开的列表

列表可以包含一组项目,这些项目将在单击时显示。 扩展列表也用于 v-navigation-drawer 组件中。

template script


  1. <template>
  2. <v-card
  3. max-width="500"
  4. class="mx-auto"
  5. >
  6. <v-toolbar
  7. color="teal"
  8. dark
  9. >
  10. <v-app-bar-nav-icon></v-app-bar-nav-icon>
  11. <v-toolbar-title>Topics</v-toolbar-title>
  12. <v-spacer></v-spacer>
  13. <v-btn icon>
  14. <v-icon>mdi-dots-vertical</v-icon>
  15. </v-btn>
  16. </v-toolbar>
  17. <v-list>
  18. <v-list-group
  19. v-for="item in items"
  20. :key="item.title"
  21. v-model="item.active"
  22. :prepend-icon="item.action"
  23. no-action
  24. >
  25. <template v-slot:activator>
  26. <v-list-item-content>
  27. <v-list-item-title v-text="item.title"></v-list-item-title>
  28. </v-list-item-content>
  29. </template>
  30. <v-list-item
  31. v-for="subItem in item.items"
  32. :key="subItem.title"
  33. @click=""
  34. >
  35. <v-list-item-content>
  36. <v-list-item-title v-text="subItem.title"></v-list-item-title>
  37. </v-list-item-content>
  38. </v-list-item>
  39. </v-list-group>
  40. </v-list>
  41. </v-card>
  42. </template>
  1. <script>
  2. export default {
  3. data () {
  4. return {
  5. items: [
  6. {
  7. action: 'local_activity',
  8. title: 'Attractions',
  9. items: [
  10. { title: 'List Item' },
  11. ],
  12. },
  13. {
  14. action: 'restaurant',
  15. title: 'Dining',
  16. active: true,
  17. items: [
  18. { title: 'Breakfast & brunch' },
  19. { title: 'New American' },
  20. { title: 'Sushi' },
  21. ],
  22. },
  23. {
  24. action: 'school',
  25. title: 'Education',
  26. items: [
  27. { title: 'List Item' },
  28. ],
  29. },
  30. {
  31. action: 'directions_run',
  32. title: 'Family',
  33. items: [
  34. { title: 'List Item' },
  35. ],
  36. },
  37. {
  38. action: 'healing',
  39. title: 'Health',
  40. items: [
  41. { title: 'List Item' },
  42. ],
  43. },
  44. {
  45. action: 'content_cut',
  46. title: 'Office',
  47. items: [
  48. { title: 'List Item' },
  49. ],
  50. },
  51. {
  52. action: 'local_offer',
  53. title: 'Promotions',
  54. items: [
  55. { title: 'List Item' },
  56. ],
  57. },
  58. ],
  59. }
  60. },
  61. }
  62. </script>

Lists(列表) - 图18

导航列表

列表可以接受一个替代的 nav 样式,它减少了 v-list-item 的宽度,并增加了一个边框半径。

template script


  1. <template>
  2. <v-card
  3. class="mx-auto"
  4. width="256"
  5. tile
  6. >
  7. <v-navigation-drawer permanent>
  8. <v-system-bar></v-system-bar>
  9. <v-list>
  10. <v-list-item>
  11. <v-list-item-avatar>
  12. <v-img src="https://cdn.vuetifyjs.com/images/john.png"></v-img>
  13. </v-list-item-avatar>
  14. </v-list-item>
  15. <v-list-item link>
  16. <v-list-item-content>
  17. <v-list-item-title class="title">John Leider</v-list-item-title>
  18. <v-list-item-subtitle>john@vuetifyjs.com</v-list-item-subtitle>
  19. </v-list-item-content>
  20. <v-list-item-action>
  21. <v-icon>mdi-menu-down</v-icon>
  22. </v-list-item-action>
  23. </v-list-item>
  24. </v-list>
  25. <v-divider></v-divider>
  26. <v-list
  27. nav
  28. dense
  29. >
  30. <v-list-item-group v-model="item" color="primary">
  31. <v-list-item
  32. v-for="(item, i) in items"
  33. :key="i"
  34. >
  35. <v-list-item-icon>
  36. <v-icon v-text="item.icon"></v-icon>
  37. </v-list-item-icon>
  38. <v-list-item-content>
  39. <v-list-item-title v-text="item.text"></v-list-item-title>
  40. </v-list-item-content>
  41. </v-list-item>
  42. </v-list-item-group>
  43. </v-list>
  44. </v-navigation-drawer>
  45. </v-card>
  46. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. item: 0,
  5. items: [
  6. { text: 'My Files', icon: 'mdi-folder' },
  7. { text: 'Shared with me', icon: 'mdi-account-multiple' },
  8. { text: 'Starred', icon: 'mdi-star' },
  9. { text: 'Recent', icon: 'mdi-history' },
  10. { text: 'Offline', icon: 'mdi-check-circle' },
  11. { text: 'Uploads', icon: 'mdi-upload' },
  12. { text: 'Backups', icon: 'mdi-cloud-upload' },
  13. ],
  14. }),
  15. }
  16. </script>

Lists(列表) - 图19