Skip to content

Step 步骤条

介绍

步骤条用于展示操作流程的各个环节,让用户了解当前的操作在整体流程中的位置。

导入

js
import Step from '@/components/display/Step.vue'
import StepItem from '@/components/display/StepItem.vue'

使用方法

基础用法

步骤条的基础用法,通过 v-model:activeIndex 来控制当前激活的步骤。

vue
<template>
  <Step v-model:activeIndex="activeIndex">
    <StepItem text="步骤1" />
    <StepItem text="步骤2" />
    <StepItem text="步骤3" />
    <StepItem text="步骤4" />
    <StepItem text="步骤5" />
    <StepItem text="步骤6" />
    <StepItem text="步骤7" />
    <StepItem text="步骤8" />
  </Step>
  <FlexRow :margin="20">
    <Button @click="activeIndex = Math.max(0, activeIndex - 1)">上一步</Button>
    <Button type="primary" @click="activeIndex = Math.min(9, activeIndex + 1)">下一步</Button>
  </FlexRow>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import Step from '@/components/display/Step.vue';
import StepItem from '@/components/display/StepItem.vue';
import FlexRow from '@/components/layout/FlexRow.vue';
import Button from '@/components/basic/Button.vue';

const activeIndex = ref(0);
</script>

自定义颜色与图标

可以通过 activeColoractiveIconinactiveIconfinishIcon 等属性设置各个状态下的图标和颜色。

vue
<template>
  <Step
    activeColor="danger"
    v-model:activeIndex="activeIndex3"
  >
    <StepItem text="步骤1" />
    <StepItem text="步骤2" activeIcon="prompt" />
    <StepItem text="步骤3" inactiveIcon="history" />
    <StepItem text="步骤4" activeIcon="history" finishIcon="film" />
  </Step>
  <FlexRow :margin="20">
    <Button @click="activeIndex3 = Math.max(0, activeIndex3 - 1)">上一步</Button>
    <Button type="primary" @click="activeIndex3 = Math.min(5, activeIndex3 + 1)">下一步</Button>
  </FlexRow>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import Step from '@/components/display/Step.vue';
import StepItem from '@/components/display/StepItem.vue';
import FlexRow from '@/components/layout/FlexRow.vue';
import Button from '@/components/basic/Button.vue';

const activeIndex3 = ref(0);
</script>

竖向步骤

可以通过设置 direction 属性来改变步骤条的显示方向为竖向。

vue
<template>
  <Step direction="vertical" v-model:activeIndex="activeIndex2">
    <StepItem text="物流状态1 2016-07-12 12:40" />
    <StepItem text="物流状态2" extra="2016-07-12 10:40" />
    <StepItem text="物流状态3" extra="2016-07-10 16:00" />
    <StepItem text="快件已发货" />
  </Step>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import Step from '@/components/display/Step.vue';
import StepItem from '@/components/display/StepItem.vue';

const activeIndex2 = ref(2);
</script>

API 参考

Step

步骤条组件容器,用于包裹多个 StepItem 组件。

Props

名称说明类型必填默认值
direction步骤条的方向'vertical' | 'horizontal'-'horizontal'
activeColor激活时的颜色string-'primary'
inactiveColor未激活时的颜色string-'lightGrey'
textColor文字颜色string-'text.content'
lineItemWidth当为水平模式时,条目的宽度number-150
lineOffset当为水平模式时,分隔线的边距偏移number-25
lineWidth线段粗细number-2
activeIndex当前激活的步骤number-
activeIcon同 StepItemProps.activeIcon,此项用于所有子条目的设置string--
inactiveIcon同 StepItemProps.inactiveIcon,此项用于所有子条目的设置string--
finishIcon同 StepItemProps.finishIcon,此项用于所有子条目的设置string--
iconProps同 StepItemProps.iconProps,此项用于所有子条目的设置IconProps--
textStyle同 StepItemProps.textStyle,此项用于所有子条目的设置TextStyle--

StepItem

步骤条的单个步骤项,需要嵌套在 Step 组件内使用。

Props

名称说明类型必填默认值
activeIcon自定义激活状态图标。为空时尝试使用 inactiveIcon 的值string-''
inactiveIcon自定义未激活状态图标。有2个特殊值 __default_number 表示一个圆圈中间一个当前步骤的序号;__default_dot 表示一个圆圈string-横向默认是 '__default_number',竖向默认是 '__default_dot'
finishIcon自定义已完成步骤对应的底部图标,优先级高于 inactiveIconstring-'success-filling'
iconProps图标的附加属性IconProps-{ size: 48 }
textStyle步骤的文字自定义样式TextStyle--
innerStyle步骤的自定义样式ViewStyle--
text当前步骤的文字string--
extra垂直模式下,允许你渲染附加内容string--

Slots

名称说明
default默认插槽,用于显示步骤内容
extra附加内容插槽,用于显示额外信息

Events

名称说明参数
click点击事件$event

主题变量

名称类型默认值说明
StepLineItemWidthnumber150水平模式时条目的宽度
StepLineOffsetnumber25水平模式时分隔线的边距偏移
StepLineWidthnumber2线段粗细
StepActiveColorstring'primary'激活时的颜色
StepInactiveColorstring'lightGrey'未激活时的颜色
StepTextColorstring'text.content'文字颜色
StepItemIconDefaultSizenumber48步骤项图标的默认大小
StepItemActiveIconstring''步骤项激活状态的默认图标
StepItemFinishIconstring'success-filling'步骤项完成状态的默认图标
StepItemMarginVerticalnumber10垂直模式下步骤项的垂直边距
StepItemTextFontSizenumber26步骤项文字的字体大小
StepItemContentFontSizenumber26步骤项内容的字体大小
StepItemContentMarginTopnumber6步骤项内容的上外边距
StepItemContentMarginLeftnumber6步骤项内容的左外边距