幻灯片组

v-slide-group 组件用于显示伪装分页信息。 它在其核心中使用 v-item-group 并为诸如 v-tabsv-chip-group 等组件提供一个基础。

用例

v-window 组件类似,v-slide-group 可以让项目占用尽可能多的空间。 允许用户通过提供的信息水平移动。

template script


  1. <template>
  2. <v-sheet
  3. class="mx-auto"
  4. max-width="700"
  5. >
  6. <v-slide-group multiple show-arrows>
  7. <v-slide-item
  8. v-for="n in 25"
  9. :key="n"
  10. v-slot:default="{ active, toggle }"
  11. >
  12. <v-btn
  13. class="mx-2"
  14. :input-value="active"
  15. active-class="purple white--text"
  16. depressed
  17. rounded
  18. @click="toggle"
  19. >
  20. Options {{ n }}
  21. </v-btn>
  22. </v-slide-item>
  23. </v-slide-group>
  24. </v-sheet>
  25. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. model: null,
  5. }),
  6. }
  7. </script>

Slide groups(幻灯片组) - 图1

API

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

Slide groups(幻灯片组) - 图2

实战场

template script


  1. <template>
  2. <div>
  3. <v-row justify="space-around">
  4. <v-switch v-model="multiple" label="Multiple"></v-switch>
  5. <v-switch v-model="mandatory" label="Mandatory"></v-switch>
  6. <v-switch v-model="showArrows" label="Show arrows"></v-switch>
  7. <v-switch v-model="prevIcon" label="Custom prev icon"></v-switch>
  8. <v-switch v-model="nextIcon" label="Custom next icon"></v-switch>
  9. <v-switch v-model="centerActive" label="Center active item"></v-switch>
  10. </v-row>
  11. <v-sheet
  12. class="mx-auto"
  13. elevation="8"
  14. max-width="800"
  15. >
  16. <v-slide-group
  17. v-model="model"
  18. class="pa-4"
  19. :prev-icon="prevIcon ? 'mdi-minus' : undefined"
  20. :next-icon="nextIcon ? 'mdi-plus' : undefined"
  21. :multiple="multiple"
  22. :mandatory="mandatory"
  23. :show-arrows="showArrows"
  24. :center-active="centerActive"
  25. >
  26. <v-slide-item
  27. v-for="n in 15"
  28. :key="n"
  29. v-slot:default="{ active, toggle }"
  30. >
  31. <v-card
  32. :color="active ? 'primary' : 'grey lighten-1'"
  33. class="ma-4"
  34. height="200"
  35. width="100"
  36. @click="toggle"
  37. >
  38. <v-row
  39. class="fill-height"
  40. align="center"
  41. justify="center"
  42. >
  43. <v-scale-transition>
  44. <v-icon
  45. v-if="active"
  46. color="white"
  47. size="48"
  48. v-text="'mdi-close-circle-outline'"
  49. ></v-icon>
  50. </v-scale-transition>
  51. </v-row>
  52. </v-card>
  53. </v-slide-item>
  54. </v-slide-group>
  55. </v-sheet>
  56. </div>
  57. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. model: null,
  5. multiple: false,
  6. mandatory: false,
  7. showArrows: true,
  8. prevIcon: false,
  9. nextIcon: false,
  10. centerActive: false,
  11. }),
  12. }
  13. </script>

Slide groups(幻灯片组) - 图3

示例

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

自定义图标

您可以添加自定义分页图标,而不是箭头

template script


  1. <template>
  2. <v-sheet
  3. class="mx-auto"
  4. elevation="8"
  5. max-width="800"
  6. >
  7. <v-slide-group
  8. v-model="model"
  9. class="pa-4"
  10. prev-icon="mdi-minus"
  11. next-icon="mdi-plus"
  12. show-arrows
  13. >
  14. <v-slide-item
  15. v-for="n in 15"
  16. :key="n"
  17. v-slot:default="{ active, toggle }"
  18. >
  19. <v-card
  20. :color="active ? 'primary' : 'grey lighten-1'"
  21. class="ma-4"
  22. height="200"
  23. width="100"
  24. @click="toggle"
  25. >
  26. <v-row
  27. class="fill-height"
  28. align="center"
  29. justify="center"
  30. >
  31. <v-scale-transition>
  32. <v-icon
  33. v-if="active"
  34. color="white"
  35. size="48"
  36. v-text="'mdi-close-circle-outline'"
  37. ></v-icon>
  38. </v-scale-transition>
  39. </v-row>
  40. </v-card>
  41. </v-slide-item>
  42. </v-slide-group>
  43. </v-sheet>
  44. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. model: null,
  5. }),
  6. }
  7. </script>

Slide groups(幻灯片组) - 图4

活动类

可以自定义活动类

template script


  1. <template>
  2. <v-sheet
  3. class="mx-auto"
  4. elevation="8"
  5. max-width="800"
  6. >
  7. <v-slide-group
  8. v-model="model"
  9. class="pa-4"
  10. active-class="success"
  11. show-arrows
  12. >
  13. <v-slide-item
  14. v-for="n in 15"
  15. :key="n"
  16. v-slot:default="{ active, toggle }"
  17. >
  18. <v-card
  19. :color="active ? undefined : 'grey lighten-1'"
  20. class="ma-4"
  21. height="200"
  22. width="100"
  23. @click="toggle"
  24. >
  25. <v-row
  26. class="fill-height"
  27. align="center"
  28. justify="center"
  29. >
  30. <v-scale-transition>
  31. <v-icon
  32. v-if="active"
  33. color="white"
  34. size="48"
  35. v-text="'mdi-close-circle-outline'"
  36. ></v-icon>
  37. </v-scale-transition>
  38. </v-row>
  39. </v-card>
  40. </v-slide-item>
  41. </v-slide-group>
  42. </v-sheet>
  43. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. model: null,
  5. }),
  6. }
  7. </script>

Slide groups(幻灯片组) - 图5

多选

您可以选择多个项目

template script


  1. <template>
  2. <v-sheet
  3. class="mx-auto"
  4. elevation="8"
  5. max-width="800"
  6. >
  7. <v-slide-group
  8. v-model="model"
  9. class="pa-4"
  10. multiple
  11. show-arrows
  12. >
  13. <v-slide-item
  14. v-for="n in 15"
  15. :key="n"
  16. v-slot:default="{ active, toggle }"
  17. >
  18. <v-card
  19. :color="active ? 'primary' : 'grey lighten-1'"
  20. class="ma-4"
  21. height="200"
  22. width="100"
  23. @click="toggle"
  24. >
  25. <v-row
  26. class="fill-height"
  27. align="center"
  28. justify="center"
  29. >
  30. <v-scale-transition>
  31. <v-icon
  32. v-if="active"
  33. color="white"
  34. size="48"
  35. v-text="'mdi-close-circle-outline'"
  36. ></v-icon>
  37. </v-scale-transition>
  38. </v-row>
  39. </v-card>
  40. </v-slide-item>
  41. </v-slide-group>
  42. </v-sheet>
  43. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. model: [],
  5. }),
  6. }
  7. </script>

Slide groups(幻灯片组) - 图6

Full-Zip Vuetify Jacket

The Vuetify Full-Zip Fleece is a great lightweight jacket to keep on hand during the chilly season.

ads by Vuetify

](https://store.vuetifyjs.com/product/full-zip-vuetify-jacket?ref=vuetifyjs.com)

必填项

必须选择至少 1 个项目

template script


  1. <template>
  2. <v-sheet
  3. class="mx-auto"
  4. elevation="8"
  5. max-width="800"
  6. >
  7. <v-slide-group
  8. v-model="model"
  9. class="pa-4"
  10. mandatory
  11. show-arrows
  12. >
  13. <v-slide-item
  14. v-for="n in 15"
  15. :key="n"
  16. v-slot:default="{ active, toggle }"
  17. >
  18. <v-card
  19. :color="active ? 'primary' : 'grey lighten-1'"
  20. class="ma-4"
  21. height="200"
  22. width="100"
  23. @click="toggle"
  24. >
  25. <v-row
  26. class="fill-height"
  27. align="center"
  28. justify="center"
  29. >
  30. <v-scale-transition>
  31. <v-icon
  32. v-if="active"
  33. color="white"
  34. size="48"
  35. v-text="'mdi-close-circle-outline'"
  36. ></v-icon>
  37. </v-scale-transition>
  38. </v-row>
  39. </v-card>
  40. </v-slide-item>
  41. </v-slide-group>
  42. </v-sheet>
  43. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. model: null,
  5. }),
  6. }
  7. </script>

Slide groups(幻灯片组) - 图7

伪轮播

自定义幻灯片组以在图纸上创造性地显示信息。 使用选择,我们可以为用户轻松显示辅助信息。

template script


  1. <template>
  2. <v-sheet
  3. class="mx-auto"
  4. elevation="8"
  5. max-width="800"
  6. >
  7. <v-slide-group
  8. v-model="model"
  9. class="pa-4"
  10. show-arrows
  11. >
  12. <v-slide-item
  13. v-for="n in 15"
  14. :key="n"
  15. v-slot:default="{ active, toggle }"
  16. >
  17. <v-card
  18. :color="active ? 'primary' : 'grey lighten-1'"
  19. class="ma-4"
  20. height="200"
  21. width="100"
  22. @click="toggle"
  23. >
  24. <v-row
  25. class="fill-height"
  26. align="center"
  27. justify="center"
  28. >
  29. <v-scale-transition>
  30. <v-icon
  31. v-if="active"
  32. color="white"
  33. size="48"
  34. v-text="'mdi-close-circle-outline'"
  35. ></v-icon>
  36. </v-scale-transition>
  37. </v-row>
  38. </v-card>
  39. </v-slide-item>
  40. </v-slide-group>
  41. <v-expand-transition>
  42. <v-sheet
  43. v-if="model != null"
  44. color="grey lighten-4"
  45. height="200"
  46. tile
  47. >
  48. <v-row
  49. class="fill-height"
  50. align="center"
  51. justify="center"
  52. >
  53. <h3 class="title">Selected {{ model }}</h3>
  54. </v-row>
  55. </v-sheet>
  56. </v-expand-transition>
  57. </v-sheet>
  58. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. model: null,
  5. }),
  6. }
  7. </script>

Slide groups(幻灯片组) - 图8

居中活动项目

活动项目总是居中

template script


  1. <template>
  2. <v-sheet
  3. class="mx-auto"
  4. elevation="8"
  5. max-width="800"
  6. >
  7. <v-slide-group
  8. v-model="model"
  9. class="pa-4"
  10. center-active
  11. show-arrows
  12. >
  13. <v-slide-item
  14. v-for="n in 15"
  15. :key="n"
  16. v-slot:default="{ active, toggle }"
  17. >
  18. <v-card
  19. :color="active ? 'primary' : 'grey lighten-1'"
  20. class="ma-4"
  21. height="200"
  22. width="100"
  23. @click="toggle"
  24. >
  25. <v-row
  26. class="fill-height"
  27. align="center"
  28. justify="center"
  29. >
  30. <v-scale-transition>
  31. <v-icon
  32. v-if="active"
  33. color="white"
  34. size="48"
  35. v-text="'mdi-close-circle-outline'"
  36. ></v-icon>
  37. </v-scale-transition>
  38. </v-row>
  39. </v-card>
  40. </v-slide-item>
  41. </v-slide-group>
  42. </v-sheet>
  43. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. model: null,
  5. }),
  6. }
  7. </script>

Slide groups(幻灯片组) - 图9