Steps步骤条 - 图1

Steps 步骤条

引导用户按照流程完成任务的导航条。

何时使用

当任务复杂或者存在先后关系时,将其分解成一系列步骤,从而简化任务。

代码演示

Steps步骤条 - 图2

基本用法

简单的步骤条。

  1. <template>
  2. <a-steps :current="1">
  3. <a-step>
  4. <!-- <span slot="title">Finished</span> -->
  5. <template #title>Finished</template>
  6. <template #description>
  7. <span>This is a description.</span>
  8. </template>
  9. </a-step>
  10. <a-step title="In Progress" sub-title="Left 00:00:08" description="This is a description." />
  11. <a-step title="Waiting" description="This is a description." />
  12. </a-steps>
  13. </template>

Steps步骤条 - 图3

迷你版

迷你版的步骤条,通过设置 <Steps size="small"> 启用.

  1. <template>
  2. <a-steps :current="1" size="small">
  3. <a-step title="Finished" />
  4. <a-step title="In Progress" />
  5. <a-step title="Waiting" />
  6. </a-steps>
  7. </template>

Steps步骤条 - 图4

带图标的步骤条

通过设置 Steps.Stepicon 属性,可以启用自定义图标。

  1. <template>
  2. <a-steps>
  3. <a-step status="finish" title="Login">
  4. <template #icon>
  5. <user-outlined />
  6. </template>
  7. </a-step>
  8. <a-step status="finish" title="Verification">
  9. <template #icon>
  10. <solution-outlined />
  11. </template>
  12. </a-step>
  13. <a-step status="process" title="Pay">
  14. <template #icon>
  15. <loading-outlined />
  16. </template>
  17. </a-step>
  18. <a-step status="wait" title="Done">
  19. <template #icon>
  20. <smile-outlined />
  21. </template>
  22. </a-step>
  23. </a-steps>
  24. </template>
  25. <script lang="ts">
  26. import { defineComponent } from 'vue';
  27. import {
  28. UserOutlined,
  29. SolutionOutlined,
  30. LoadingOutlined,
  31. SmileOutlined,
  32. } from '@ant-design/icons-vue';
  33. export default defineComponent({
  34. components: {
  35. UserOutlined,
  36. SolutionOutlined,
  37. LoadingOutlined,
  38. SmileOutlined,
  39. },
  40. });
  41. </script>

Steps步骤条 - 图5

步骤切换

通常配合内容及按钮使用,表示一个流程的处理进度。

  1. <template>
  2. <div>
  3. <a-steps :current="current">
  4. <a-step v-for="item in steps" :key="item.title" :title="item.title" />
  5. </a-steps>
  6. <div class="steps-content">
  7. {{ steps[current].content }}
  8. </div>
  9. <div class="steps-action">
  10. <a-button v-if="current < steps.length - 1" type="primary" @click="next">Next</a-button>
  11. <a-button
  12. v-if="current == steps.length - 1"
  13. type="primary"
  14. @click="$message.success('Processing complete!')"
  15. >
  16. Done
  17. </a-button>
  18. <a-button v-if="current > 0" style="margin-left: 8px" @click="prev">Previous</a-button>
  19. </div>
  20. </div>
  21. </template>
  22. <script lang="ts">
  23. import { defineComponent, ref } from 'vue';
  24. export default defineComponent({
  25. setup() {
  26. const current = ref<number>(0);
  27. const next = () => {
  28. current.value++;
  29. };
  30. const prev = () => {
  31. current.value--;
  32. };
  33. return {
  34. current,
  35. steps: [
  36. {
  37. title: 'First',
  38. content: 'First-content',
  39. },
  40. {
  41. title: 'Second',
  42. content: 'Second-content',
  43. },
  44. {
  45. title: 'Last',
  46. content: 'Last-content',
  47. },
  48. ],
  49. next,
  50. prev,
  51. };
  52. },
  53. });
  54. </script>
  55. <style scoped>
  56. .steps-content {
  57. margin-top: 16px;
  58. border: 1px dashed #e9e9e9;
  59. border-radius: 6px;
  60. background-color: #fafafa;
  61. min-height: 200px;
  62. text-align: center;
  63. padding-top: 80px;
  64. }
  65. .steps-action {
  66. margin-top: 24px;
  67. }
  68. </style>

Steps步骤条 - 图6

竖直方向的步骤条

简单的竖直方向的步骤条。

  1. <template>
  2. <a-steps direction="vertical" :current="1">
  3. <a-step title="Finished" description="This is a description." />
  4. <a-step title="In Progress" description="This is a description." />
  5. <a-step title="Waiting" description="This is a description." />
  6. </a-steps>
  7. </template>

Steps步骤条 - 图7

竖直方向的小型步骤条

简单的竖直方向的小型步骤条。

  1. <template>
  2. <a-steps direction="vertical" size="small" :current="1">
  3. <a-step title="Finished" description="This is a description." />
  4. <a-step title="In Progress" description="This is a description." />
  5. <a-step title="Waiting" description="This is a description." />
  6. </a-steps>
  7. </template>

Steps步骤条 - 图8

步骤运行错误

使用 Steps 的 status 属性来指定当前步骤的状态。

  1. <template>
  2. <a-steps :current="1" status="error">
  3. <a-step title="Finished" description="This is a description." />
  4. <a-step title="In Progress" description="This is a description." />
  5. <a-step title="Waiting" description="This is a description." />
  6. </a-steps>
  7. </template>

Steps步骤条 - 图9

点状步骤条

包含步骤点的进度条。

  1. <template>
  2. <div>
  3. <a-steps progress-dot :current="1">
  4. <a-step title="Finished" description="This is a description." />
  5. <a-step title="In Progress" description="This is a description." />
  6. <a-step title="Waiting" description="This is a description." />
  7. </a-steps>
  8. <a-divider />
  9. <a-steps progress-dot :current="1" direction="vertical">
  10. <a-step title="Finished" description="This is a description. This is a description." />
  11. <a-step title="Finished" description="This is a description. This is a description." />
  12. <a-step title="In Progress" description="This is a description. This is a description." />
  13. <a-step title="Waiting" description="This is a description." />
  14. <a-step title="Waiting" description="This is a description." />
  15. </a-steps>
  16. </div>
  17. </template>

Steps步骤条 - 图10

自定义点状步骤条

为点状步骤条增加自定义展示。

  1. <template>
  2. <div>
  3. <a-steps :current="1">
  4. <template #progressDot="{ index, status, prefixCls }">
  5. <a-popover>
  6. <template #content>
  7. <span>step {{ index }} status: {{ status }}</span>
  8. </template>
  9. <span :class="`${prefixCls}-icon-dot`" />
  10. </a-popover>
  11. </template>
  12. <a-step title="Finished" description="You can hover on the dot." />
  13. <a-step title="In Progress" description="You can hover on the dot." />
  14. <a-step title="Waiting" description="You can hover on the dot." />
  15. <a-step title="Waiting" description="You can hover on the dot." />
  16. </a-steps>
  17. </div>
  18. </template>

Steps步骤条 - 图11

可点击

设置 v-model 后,Steps 变为可点击状态。

  1. <template>
  2. <div>
  3. <a-steps v-model:current="current">
  4. <a-step title="Step 1" description="This is a description." />
  5. <a-step title="Step 2" description="This is a description." />
  6. <a-step title="Step 3" description="This is a description." />
  7. </a-steps>
  8. <a-divider />
  9. <a-steps v-model:current="current" direction="vertical">
  10. <a-step title="Step 1" description="This is a description." />
  11. <a-step title="Step 2" description="This is a description." />
  12. <a-step title="Step 3" description="This is a description." />
  13. </a-steps>
  14. </div>
  15. </template>
  16. <script lang="ts">
  17. import { defineComponent, ref } from 'vue';
  18. export default defineComponent({
  19. setup() {
  20. const current = ref<number>(0);
  21. return {
  22. current,
  23. };
  24. },
  25. });
  26. </script>

Steps步骤条 - 图12

导航步骤

导航类型的步骤条。

  1. <template>
  2. <div>
  3. <a-steps v-model:current="current" type="navigation" size="small" :style="stepStyle">
  4. <a-step
  5. title="Step 1"
  6. sub-title="00:00:05"
  7. status="finish"
  8. description="This is a description."
  9. />
  10. <a-step
  11. title="Step 2"
  12. sub-title="00:01:02"
  13. status="process"
  14. description="This is a description."
  15. />
  16. <a-step
  17. title="Step 3"
  18. sub-title="waiting for longlong time"
  19. status="wait"
  20. description="This is a description."
  21. />
  22. </a-steps>
  23. <a-steps v-model:current="current" type="navigation" :style="stepStyle">
  24. <a-step status="finish" title="Step 1" />
  25. <a-step status="process" title="Step 2" />
  26. <a-step status="wait" title="Step 3" />
  27. <a-step status="wait" title="Step 4" />
  28. </a-steps>
  29. <a-steps v-model:current="current" type="navigation" size="small" :style="stepStyle">
  30. <a-step status="finish" title="finish 1" />
  31. <a-step status="finish" title="finish 2" />
  32. <a-step status="process" title="current process" />
  33. <a-step status="wait" title="wait" disabled />
  34. </a-steps>
  35. </div>
  36. </template>
  37. <script lang="ts">
  38. import { defineComponent, ref } from 'vue';
  39. export default defineComponent({
  40. setup() {
  41. const current = ref<number>(0);
  42. return {
  43. current,
  44. stepStyle: {
  45. marginBottom: '60px',
  46. boxShadow: '0px -1px 0 0 #e8e8e8 inset',
  47. },
  48. };
  49. },
  50. });
  51. </script>

API

  1. <a-steps>
  2. <a-step title="第一步" />
  3. <a-step title="第二步" />
  4. <a-step title="第三步" />
  5. </a-steps>

Steps

整体步骤条。

参数说明类型默认值版本
type步骤条类型,有 defaultnavigation 两种stringdefault1.5.0
current (v-model)指定当前步骤,从 0 开始记数。在子 Step 元素中,可以通过 status 属性覆盖状态, 1.5.0 后支持 v-modelnumber0
direction指定步骤条方向。目前支持水平(horizontal)和竖直(vertical)两种方向stringhorizontal
labelPlacement指定标签放置位置,默认水平放图标右侧,可选vertical放图标下方stringhorizontal
progressDot点状步骤条,可以设置为一个 作用域插槽,labelPlacement 将强制为verticalBoolean or slot=”progressDot” slot-scope=”{index, status, title, description, prefixCls})”false
size指定大小,目前支持普通(default)和迷你(smallstringdefault
status指定当前步骤的状态,可选 wait process finish errorstringprocess
initial起始序号,从 0 开始记数number0

Steps 事件

事件名称说明回调参数版本
change点击切换步骤时触发(current) => void-

Steps.Step

步骤条内的每一个步骤。

参数说明类型默认值版本
description步骤的详情描述,可选string | slot-
icon步骤图标的类型,可选string | slot-
status指定状态。当不配置该属性时,会使用 Steps 的 current 来自动指定状态。可选:wait process finish errorstringwait
title标题string | slot-
subTitle子标题string | slot-1.5.0
disabled禁用点击booleanfalse1.5.0