步骤条

v-stepper 组件用于显示步骤进度。

用例

一个步骤组件适用于多种场景,包括购物车、创建记录等等。

template script


  1. <template>
  2. <v-stepper v-model="e1">
  3. <v-stepper-header>
  4. <v-stepper-step :complete="e1 > 1" step="1">Name of step 1</v-stepper-step>
  5. <v-divider></v-divider>
  6. <v-stepper-step :complete="e1 > 2" step="2">Name of step 2</v-stepper-step>
  7. <v-divider></v-divider>
  8. <v-stepper-step step="3">Name of step 3</v-stepper-step>
  9. </v-stepper-header>
  10. <v-stepper-items>
  11. <v-stepper-content step="1">
  12. <v-card
  13. class="mb-12"
  14. color="grey lighten-1"
  15. height="200px"
  16. ></v-card>
  17. <v-btn
  18. color="primary"
  19. @click="e1 = 2"
  20. >
  21. Continue
  22. </v-btn>
  23. <v-btn text>Cancel</v-btn>
  24. </v-stepper-content>
  25. <v-stepper-content step="2">
  26. <v-card
  27. class="mb-12"
  28. color="grey lighten-1"
  29. height="200px"
  30. ></v-card>
  31. <v-btn
  32. color="primary"
  33. @click="e1 = 3"
  34. >
  35. Continue
  36. </v-btn>
  37. <v-btn text>Cancel</v-btn>
  38. </v-stepper-content>
  39. <v-stepper-content step="3">
  40. <v-card
  41. class="mb-12"
  42. color="grey lighten-1"
  43. height="200px"
  44. ></v-card>
  45. <v-btn
  46. color="primary"
  47. @click="e1 = 1"
  48. >
  49. Continue
  50. </v-btn>
  51. <v-btn text>Cancel</v-btn>
  52. </v-stepper-content>
  53. </v-stepper-items>
  54. </v-stepper>
  55. </template>
  1. <script>
  2. export default {
  3. data () {
  4. return {
  5. e1: 1,
  6. }
  7. },
  8. }
  9. </script>

Steppers(步骤条) - 图1

API

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

Steppers(步骤条) - 图2

实战场

template script


  1. <template>
  2. <div>
  3. <v-row justify="space-around">
  4. <v-col cols="12">
  5. <v-slider v-model="steps" label="Steps" min="2" max="20"></v-slider>
  6. </v-col>
  7. <v-switch v-model="vertical" label="Vertical"></v-switch>
  8. <v-switch v-model="altLabels" label="altLabels"></v-switch>
  9. <v-switch v-model="editable" label="Editable"></v-switch>
  10. </v-row>
  11. <v-stepper
  12. v-model="e1"
  13. :vertical="vertical"
  14. :alt-labels="altLabels"
  15. >
  16. <template v-if="vertical">
  17. <template v-for="n in steps">
  18. <v-stepper-step
  19. :key="`${n}-step`"
  20. :complete="e1 > n"
  21. :step="n"
  22. :editable="editable"
  23. >
  24. Step {{ n }}
  25. </v-stepper-step>
  26. <v-stepper-content
  27. :key="`${n}-content`"
  28. :step="n"
  29. >
  30. <v-card
  31. class="mb-12"
  32. color="grey lighten-1"
  33. height="200px"
  34. ></v-card>
  35. <v-btn
  36. color="primary"
  37. @click="nextStep(n)"
  38. >
  39. Continue
  40. </v-btn>
  41. <v-btn text>Cancel</v-btn>
  42. </v-stepper-content>
  43. </template>
  44. </template>
  45. <template v-else>
  46. <v-stepper-header>
  47. <template v-for="n in steps">
  48. <v-stepper-step
  49. :key="`${n}-step`"
  50. :complete="e1 > n"
  51. :step="n"
  52. :editable="editable"
  53. >
  54. Step {{ n }}
  55. </v-stepper-step>
  56. <v-divider
  57. v-if="n !== steps"
  58. :key="n"
  59. ></v-divider>
  60. </template>
  61. </v-stepper-header>
  62. <v-stepper-items>
  63. <v-stepper-content
  64. v-for="n in steps"
  65. :key="`${n}-content`"
  66. :step="n"
  67. >
  68. <v-card
  69. class="mb-12"
  70. color="grey lighten-1"
  71. height="200px"
  72. ></v-card>
  73. <v-btn
  74. color="primary"
  75. @click="nextStep(n)"
  76. >
  77. Continue
  78. </v-btn>
  79. <v-btn text>Cancel</v-btn>
  80. </v-stepper-content>
  81. </v-stepper-items>
  82. </template>
  83. </v-stepper>
  84. </div>
  85. </template>
  1. <script>
  2. export default {
  3. data () {
  4. return {
  5. e1: 1,
  6. steps: 2,
  7. vertical: false,
  8. altLabels: false,
  9. editable: true,
  10. }
  11. },
  12. watch: {
  13. steps (val) {
  14. if (this.e1 > val) {
  15. this.e1 = val
  16. }
  17. },
  18. vertical () {
  19. this.e1 = 2
  20. requestAnimationFrame(() => this.e1 = 1) // Workarounds
  21. },
  22. },
  23. methods: {
  24. onInput (val) {
  25. this.steps = parseInt(val)
  26. },
  27. nextStep (n) {
  28. if (n === this.steps) {
  29. this.e1 = 1
  30. } else {
  31. this.e1 = n + 1
  32. }
  33. },
  34. },
  35. }
  36. </script>

Steppers(步骤条) - 图3

示例

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

可编辑步骤

用户随时可以选择可编辑的步骤并将跳转到该步。

template


  1. <template>
  2. <v-stepper>
  3. <v-stepper-header>
  4. <v-stepper-step
  5. complete
  6. editable
  7. step="1"
  8. >
  9. Select campaign settings
  10. </v-stepper-step>
  11. <v-divider></v-divider>
  12. <v-stepper-step
  13. complete
  14. step="2"
  15. >Create an ad group</v-stepper-step>
  16. <v-divider></v-divider>
  17. <v-stepper-step
  18. step="3"
  19. editable
  20. >
  21. Create an ad
  22. </v-stepper-step>
  23. </v-stepper-header>
  24. </v-stepper>
  25. </template>

Steppers(步骤条) - 图4

不可编辑步骤

不可编辑步骤(Non-editable steps)强制用户在整个流程中进行线性处理。

template


  1. <template>
  2. <v-stepper value="2">
  3. <v-stepper-header>
  4. <v-stepper-step step="1" complete>Select campaign settings</v-stepper-step>
  5. <v-divider></v-divider>
  6. <v-stepper-step step="2">Create an ad group</v-stepper-step>
  7. <v-divider></v-divider>
  8. <v-stepper-step step="3">Create an ad</v-stepper-step>
  9. </v-stepper-header>
  10. </v-stepper>
  11. </template>

Steppers(步骤条) - 图5

可选步骤

可选步骤可由子文本调出。

template


  1. <template>
  2. <div>
  3. <v-stepper value="1">
  4. <v-stepper-header>
  5. <v-stepper-step step="1">Select campaign settings</v-stepper-step>
  6. <v-divider></v-divider>
  7. <v-stepper-step step="2">
  8. Create an ad group
  9. <small>Optional</small>
  10. </v-stepper-step>
  11. <v-divider></v-divider>
  12. <v-stepper-step step="3">Create an ad</v-stepper-step>
  13. </v-stepper-header>
  14. </v-stepper>
  15. <v-stepper value="2" class="mt-12">
  16. <v-stepper-header>
  17. <v-stepper-step step="1" complete>Select campaign settings</v-stepper-step>
  18. <v-divider></v-divider>
  19. <v-stepper-step step="2">
  20. Create an ad group
  21. <small>Optional</small>
  22. </v-stepper-step>
  23. <v-divider></v-divider>
  24. <v-stepper-step step="3">Create an ad</v-stepper-step>
  25. </v-stepper-header>
  26. </v-stepper>
  27. </div>
  28. </template>

Steppers(步骤条) - 图6

水平步骤线

水平步骤线通过定义的步骤将用户沿 x轴 移动。

template


  1. <template>
  2. <v-stepper value="1">
  3. <v-stepper-header>
  4. <v-stepper-step step="1">Select campaign settings</v-stepper-step>
  5. <v-divider></v-divider>
  6. <v-stepper-step step="2">Create an ad group</v-stepper-step>
  7. <v-divider></v-divider>
  8. <v-stepper-step step="3">Create an ad</v-stepper-step>
  9. </v-stepper-header>
  10. </v-stepper>
  11. </template>

Steppers(步骤条) - 图7

垂直步骤线

水平步骤线通过定义的步骤将用户沿 y轴 移动。其他地方与水平方向的一致。

template script


  1. <template>
  2. <v-stepper v-model="e6" vertical>
  3. <v-stepper-step :complete="e6 > 1" step="1">
  4. Select an app
  5. <small>Summarize if needed</small>
  6. </v-stepper-step>
  7. <v-stepper-content step="1">
  8. <v-card color="grey lighten-1" class="mb-12" height="200px"></v-card>
  9. <v-btn color="primary" @click="e6 = 2">Continue</v-btn>
  10. <v-btn text>Cancel</v-btn>
  11. </v-stepper-content>
  12. <v-stepper-step :complete="e6 > 2" step="2">Configure analytics for this app</v-stepper-step>
  13. <v-stepper-content step="2">
  14. <v-card color="grey lighten-1" class="mb-12" height="200px"></v-card>
  15. <v-btn color="primary" @click="e6 = 3">Continue</v-btn>
  16. <v-btn text>Cancel</v-btn>
  17. </v-stepper-content>
  18. <v-stepper-step :complete="e6 > 3" step="3">Select an ad format and name ad unit</v-stepper-step>
  19. <v-stepper-content step="3">
  20. <v-card color="grey lighten-1" class="mb-12" height="200px"></v-card>
  21. <v-btn color="primary" @click="e6 = 4">Continue</v-btn>
  22. <v-btn text>Cancel</v-btn>
  23. </v-stepper-content>
  24. <v-stepper-step step="4">View setup instructions</v-stepper-step>
  25. <v-stepper-content step="4">
  26. <v-card color="grey lighten-1" class="mb-12" height="200px"></v-card>
  27. <v-btn color="primary" @click="e6 = 1">Continue</v-btn>
  28. <v-btn text>Cancel</v-btn>
  29. </v-stepper-content>
  30. </v-stepper>
  31. </template>
  1. <script>
  2. export default {
  3. data () {
  4. return {
  5. e6: 1,
  6. }
  7. },
  8. }
  9. </script>

Steppers(步骤条) - 图8

线性步骤

线性步骤始终沿着你定义的路径移动。

template


  1. <template>
  2. <div>
  3. <v-stepper>
  4. <v-stepper-header>
  5. <v-stepper-step step="1">Select campaign settings</v-stepper-step>
  6. <v-divider></v-divider>
  7. <v-stepper-step step="2">Create an ad group</v-stepper-step>
  8. <v-divider></v-divider>
  9. <v-stepper-step step="3">Create an ad</v-stepper-step>
  10. </v-stepper-header>
  11. </v-stepper>
  12. <v-stepper value="2" class="mt-12">
  13. <v-stepper-header>
  14. <v-stepper-step step="1" complete>Select campaign settings</v-stepper-step>
  15. <v-divider></v-divider>
  16. <v-stepper-step step="2">Create an ad group</v-stepper-step>
  17. <v-divider></v-divider>
  18. <v-stepper-step step="3">Create an ad</v-stepper-step>
  19. </v-stepper-header>
  20. </v-stepper>
  21. <v-stepper value="3" class="mt-12">
  22. <v-stepper-header>
  23. <v-stepper-step step="1" complete>Select campaign settings</v-stepper-step>
  24. <v-divider></v-divider>
  25. <v-stepper-step step="2" complete>Create an ad group</v-stepper-step>
  26. <v-divider></v-divider>
  27. <v-stepper-step step="3">Create an ad</v-stepper-step>
  28. </v-stepper-header>
  29. </v-stepper>
  30. </div>
  31. </template>

Steppers(步骤条) - 图9

Vuetify Reddit

Connect with developers across the globe on the Vuetify subreddit.

ads by Vuetify

](https://www.reddit.com/r/vuetifyjs/?ref=vuetifyjs.com)

非线性步骤

非线性步骤可以让用户按照自己选择路线在流程中移动。

template


  1. <template>
  2. <div>
  3. <v-stepper non-linear>
  4. <v-stepper-header>
  5. <v-stepper-step
  6. editable
  7. step="1"
  8. >
  9. Select campaign settings
  10. </v-stepper-step>
  11. <v-divider></v-divider>
  12. <v-stepper-step
  13. editable
  14. step="2"
  15. >
  16. Create an ad group
  17. </v-stepper-step>
  18. <v-divider></v-divider>
  19. <v-stepper-step
  20. step="3"
  21. editable
  22. >
  23. Create an ad
  24. </v-stepper-step>
  25. </v-stepper-header>
  26. </v-stepper>
  27. <v-stepper
  28. class="mt-12"
  29. non-linear
  30. >
  31. <v-stepper-header>
  32. <v-stepper-step
  33. complete
  34. editable
  35. step="1"
  36. >
  37. Select campaign settings
  38. </v-stepper-step>
  39. <v-divider></v-divider>
  40. <v-stepper-step
  41. editable
  42. step="2"
  43. >
  44. Create an ad group
  45. </v-stepper-step>
  46. <v-divider></v-divider>
  47. <v-stepper-step
  48. complete
  49. editable
  50. step="3"
  51. >
  52. Create an ad
  53. </v-stepper-step>
  54. </v-stepper-header>
  55. </v-stepper>
  56. <v-stepper
  57. class="mt-12"
  58. non-linear
  59. value="3"
  60. >
  61. <v-stepper-header>
  62. <v-stepper-step
  63. complete
  64. editable
  65. step="1"
  66. >
  67. Select campaign settings
  68. </v-stepper-step>
  69. <v-divider></v-divider>
  70. <v-stepper-step
  71. complete
  72. editable
  73. step="2"
  74. >
  75. Create an ad group
  76. </v-stepper-step>
  77. <v-divider></v-divider>
  78. <v-stepper-step
  79. complete
  80. editable
  81. step="3"
  82. >
  83. Create an ad
  84. </v-stepper-step>
  85. </v-stepper-header>
  86. </v-stepper>
  87. </div>
  88. </template>

Steppers(步骤条) - 图10

备用标签

步骤组件也有一个放置在步骤下方的备用标签样式。

template


  1. <template>
  2. <div>
  3. <v-stepper alt-labels>
  4. <v-stepper-header>
  5. <v-stepper-step step="1">Ad unit details</v-stepper-step>
  6. <v-divider></v-divider>
  7. <v-stepper-step step="2">Ad sizes</v-stepper-step>
  8. <v-divider></v-divider>
  9. <v-stepper-step step="3">Ad templates</v-stepper-step>
  10. </v-stepper-header>
  11. </v-stepper>
  12. <v-stepper alt-labels class="mt-12">
  13. <v-stepper-header>
  14. <v-stepper-step step="1">Ad unit details</v-stepper-step>
  15. <v-divider></v-divider>
  16. <v-stepper-step step="2">
  17. Ad sizes
  18. <small>Optional</small>
  19. </v-stepper-step>
  20. <v-divider></v-divider>
  21. <v-stepper-step step="3">Ad templates</v-stepper-step>
  22. </v-stepper-header>
  23. </v-stepper>
  24. </div>
  25. </template>

Steppers(步骤条) - 图11

多行表示的错误状态

可以显示错误状态来通知用户必须采取的一些行动。

template


  1. <template>
  2. <v-stepper>
  3. <v-stepper-header>
  4. <v-stepper-step step="1">Ad unit details</v-stepper-step>
  5. <v-divider></v-divider>
  6. <v-stepper-step :rules="[() => false]" step="2">
  7. Ad templates
  8. <small>Alert message</small>
  9. </v-stepper-step>
  10. <v-divider></v-divider>
  11. <v-stepper-step step="3">Ad sizes</v-stepper-step>
  12. </v-stepper-header>
  13. </v-stepper>
  14. </template>

Steppers(步骤条) - 图12

备用标签样式的多行错误状态显示

错误状态的显示同样可以应用于备用标签样式。

template


  1. <template>
  2. <v-stepper alt-labels>
  3. <v-stepper-header>
  4. <v-stepper-step step="3" complete>Ad type</v-stepper-step>
  5. <v-divider></v-divider>
  6. <v-stepper-step step="4" complete>Ad style</v-stepper-step>
  7. <v-divider></v-divider>
  8. <v-stepper-step :rules="[() => false]" step="5">
  9. Custom channels
  10. <small>Alert message</small>
  11. </v-stepper-step>
  12. <v-divider></v-divider>
  13. <v-stepper-step step="6">Get code</v-stepper-step>
  14. </v-stepper-header>
  15. </v-stepper>
  16. </template>

Steppers(步骤条) - 图13

垂直的多行错误状态显示

同样的,错误状态也可以应用于垂直的步骤。

template script


  1. <template>
  2. <v-stepper v-model="e13" vertical>
  3. <v-stepper-step step="1" complete>
  4. Name of step 1
  5. </v-stepper-step>
  6. <v-stepper-content step="1">
  7. <v-card color="grey lighten-1" class="mb-12" height="200px"></v-card>
  8. <v-btn color="primary" @click="e13 = 2">Continue</v-btn>
  9. <v-btn text>Cancel</v-btn>
  10. </v-stepper-content>
  11. <v-stepper-step step="2" complete>Name of step 2</v-stepper-step>
  12. <v-stepper-content step="2">
  13. <v-card color="grey lighten-1" class="mb-12" height="200px"></v-card>
  14. <v-btn color="primary" @click="e13 = 3">Continue</v-btn>
  15. <v-btn text>Cancel</v-btn>
  16. </v-stepper-content>
  17. <v-stepper-step :rules="[() => false]" step="3">
  18. Ad templates
  19. <small>Alert message</small>
  20. </v-stepper-step>
  21. <v-stepper-content step="3">
  22. <v-card color="grey lighten-1" class="mb-12" height="200px"></v-card>
  23. <v-btn color="primary" @click="e13 = 4">Continue</v-btn>
  24. <v-btn text>Cancel</v-btn>
  25. </v-stepper-content>
  26. <v-stepper-step step="4">View setup instructions</v-stepper-step>
  27. <v-stepper-content step="4">
  28. <v-card color="grey lighten-1" class="mb-12" height="200px"></v-card>
  29. <v-btn color="primary" @click="e13 = 1">Continue</v-btn>
  30. <v-btn text>Cancel</v-btn>
  31. </v-stepper-content>
  32. </v-stepper>
  33. </template>
  1. <script>
  2. export default {
  3. data () {
  4. return {
  5. e13: 2,
  6. }
  7. },
  8. }
  9. </script>

Steppers(步骤条) - 图14

动态步骤

步骤可以动态的添加和移除,如果删除的是当前处于激活状态的步骤,请务必通过更改应用模型来解决这个问题。

template script


  1. <template>
  2. <div>
  3. <v-card class="mb-4">
  4. <v-card-text>
  5. <v-select
  6. v-model="steps"
  7. :items="[2, 3, 4, 5, 6]"
  8. label="# of steps"
  9. ></v-select>
  10. </v-card-text>
  11. </v-card>
  12. <v-stepper v-model="e1">
  13. <v-stepper-header>
  14. <template v-for="n in steps">
  15. <v-stepper-step
  16. :key="`${n}-step`"
  17. :complete="e1 > n"
  18. :step="n"
  19. editable
  20. >
  21. Step {{ n }}
  22. </v-stepper-step>
  23. <v-divider
  24. v-if="n !== steps"
  25. :key="n"
  26. ></v-divider>
  27. </template>
  28. </v-stepper-header>
  29. <v-stepper-items>
  30. <v-stepper-content
  31. v-for="n in steps"
  32. :key="`${n}-content`"
  33. :step="n"
  34. >
  35. <v-card
  36. class="mb-12"
  37. color="grey lighten-1"
  38. height="200px"
  39. ></v-card>
  40. <v-btn
  41. color="primary"
  42. @click="nextStep(n)"
  43. >
  44. Continue
  45. </v-btn>
  46. <v-btn text>Cancel</v-btn>
  47. </v-stepper-content>
  48. </v-stepper-items>
  49. </v-stepper>
  50. </div>
  51. </template>
  1. <script>
  2. export default {
  3. data () {
  4. return {
  5. e1: 1,
  6. steps: 2,
  7. }
  8. },
  9. watch: {
  10. steps (val) {
  11. if (this.e1 > val) {
  12. this.e1 = val
  13. }
  14. },
  15. },
  16. methods: {
  17. nextStep (n) {
  18. if (n === this.steps) {
  19. this.e1 = 1
  20. } else {
  21. this.e1 = n + 1
  22. }
  23. },
  24. },
  25. }
  26. </script>

Steppers(步骤条) - 图15