Skip to content

Steps 步骤条

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

代码演示

基础用法

简单的步骤条。

Finished
This is a description.
2
In Progress
Left 00:00:08
This is a description.
3
Waiting
This is a description.
vue
<template>
  <a-steps
    :current="1"
    :items="[
      {
        title: 'Finished',
        description,
      },
      {
        title: 'In Progress',
        description,
        subTitle: 'Left 00:00:08',
      },
      {
        title: 'Waiting',
        description,
      },
    ]"
  ></a-steps>
</template>
<script setup>
const description = 'This is a description.';
</script>

步骤切换

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

1
First
2
Second
3
Last
First-content
vue
<template>
  <div>
    <a-steps :current="current" :items="items"></a-steps>
    <div class="steps-content">
      {{ steps[current].content }}
    </div>
    <div class="steps-action">
      <a-button v-if="current < steps.length - 1" type="primary" @click="next">Next</a-button>
      <a-button
        v-if="current == steps.length - 1"
        type="primary"
        @click="message.success('Processing complete!')"
      >
        Done
      </a-button>
      <a-button v-if="current > 0" style="margin-left: 8px" @click="prev">Previous</a-button>
    </div>
  </div>
</template>
<script setup>
import { ref } from 'vue';
const current = ref(0);
const next = () => {
  current.value++;
};
const prev = () => {
  current.value--;
};
const steps = [
  {
    title: 'First',
    content: 'First-content',
  },
  {
    title: 'Second',
    content: 'Second-content',
  },
  {
    title: 'Last',
    content: 'Last-content',
  },
];
const items = steps.map(item => ({
  key: item.title,
  title: item.title,
}));
</script>
<style scoped>
.steps-content {
  margin-top: 16px;
  border: 1px dashed #e9e9e9;
  border-radius: 6px;
  background-color: #fafafa;
  min-height: 200px;
  text-align: center;
  padding-top: 80px;
}

.steps-action {
  margin-top: 24px;
}

[data-theme='dark'] .steps-content {
  background-color: #2f2f2f;
  border: 1px dashed #404040;
}
</style>

竖直方向的步骤条

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

Finished
This is a description.
2
In Progress
This is a description.
3
Waiting
This is a description.
vue
<template>
  <a-steps
    direction="vertical"
    :current="1"
    :items="[
      {
        title: 'Finished',
        description,
      },
      {
        title: 'In Progress',
        description,
      },
      {
        title: 'Waiting',
        description,
      },
    ]"
  ></a-steps>
</template>
<script setup>
const description = 'This is a description.';
</script>

步骤运行错误

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

Finished
This is a description.
In Process
This is a description.
3
Waiting
This is a description.
vue
<template>
  <a-steps
    v-model:current="current"
    status="error"
    :items="[
      {
        title: 'Finished',
        description,
      },
      {
        title: 'In Process',
        description,
      },
      {
        title: 'Waiting',
        description,
      },
    ]"
  ></a-steps>
</template>
<script setup>
import { ref } from 'vue';
const current = ref(1);
const description = 'This is a description.';
</script>

可点击

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

1
Step 1
This is a description.
2
Step 2
This is a description.
3
Step 3
This is a description.
1
Step 1
This is a description.
2
Step 2
This is a description.
3
Step 3
This is a description.
vue
<template>
  <div>
    <a-steps
      v-model:current="current"
      :items="[
        {
          title: 'Step 1',
          description,
        },
        {
          title: 'Step 2',
          description,
        },
        {
          title: 'Step 3',
          description,
        },
      ]"
    ></a-steps>
    <a-divider />
    <a-steps
      v-model:current="current"
      direction="vertical"
      :items="[
        {
          title: 'Step 1',
          description,
        },
        {
          title: 'Step 2',
          description,
        },
        {
          title: 'Step 3',
          description,
        },
      ]"
    ></a-steps>
  </div>
</template>
<script setup>
import { ref } from 'vue';
const current = ref(0);
const description = 'This is a description.';
</script>

带有进度的步骤

带有进度的步骤。

Finished
This is a description.
2
In Progress
Left 00:00:08
This is a description.
3
Waiting
This is a description.
Finished
This is a description.
2
In Progress
Left 00:00:08
This is a description.
3
Waiting
This is a description.
vue
<template>
  <a-steps
    v-model:current="current"
    :percent="60"
    :items="[
      {
        title: 'Finished',
        description,
      },
      {
        title: 'In Progress',
        subTitle: 'Left 00:00:08',
        description,
      },
      {
        title: 'Waiting',
        description,
      },
    ]"
  ></a-steps>
  <a-steps
    v-model:current="current"
    :percent="60"
    size="small"
    :items="[
      {
        title: 'Finished',
        description,
      },
      {
        title: 'In Progress',
        subTitle: 'Left 00:00:08',
        description,
      },
      {
        title: 'Waiting',
        description,
      },
    ]"
  ></a-steps>
</template>
<script setup>
import { ref } from 'vue';
const current = ref(1);
const description = 'This is a description.';
</script>

API

Steps

整体步骤条。

参数说明类型默认值
current(v-model) 指定当前步骤,从 0 开始记数。在子 Step 元素中,可以通过 status 属性覆盖状态number0
direction指定步骤条方向。目前支持水平(horizontal)和竖直(vertical)两种方向stringhorizontal
initial起始序号,从 0 开始记数number0
labelPlacement指定标签放置位置,默认水平放图标右侧,可选vertical放图标下方stringhorizontal
percent当前 process 步骤显示的进度条进度(只对基本类型的 Steps 生效)number-
progressDot点状步骤条,可以设置为一个 作用域插槽,labelPlacement 将强制为verticalBoolean or v-slot:progressDot="{index, status, title, description, prefixCls, iconDot}"false
responsive当屏幕宽度小于 532px 时自动变为垂直模式booleantrue
size指定大小,目前支持普通(default)和迷你(smallstringdefault
status指定当前步骤的状态,可选 wait process finish errorstringprocess
type步骤条类型,有 defaultnavigation 两种stringdefault
items配置选项卡内容StepItem[][]

type="inline"

参数说明类型默认值
current指定当前步骤,从 0 开始记数。在子 Step 元素中,可以通过 status 属性覆盖状态number0
initial起始序号,从 0 开始记数number0
status指定当前步骤的状态,可选 wait process finish errorstringprocess
items配置选项卡内容,不支持 icon subtitleStepItem[]

Steps 事件

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

Steps.Step

步骤条内的每一个步骤。

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