Steps 步骤条
数据驱动的步骤状态;支持受控 active、横向和纵向排列。
引入
uni-app 配置 easycom 后使用 <hui-steps>。公开类型和函数从 @nscode/handy-uni 导入;普通 Vue 3 安装 @nscode/handy-uni/web 预览插件。
示例
示例可独立运行;交互结果直接显示在页面。
vue
<template>
<view>
<hui-space direction="vertical" fill>
<hui-steps
v-model:active="active"
custom-class="hui-space__item"
:items="items"
clickable
@change="onChange"
/>
<hui-steps
custom-class="hui-space__item"
:items="items"
:active="1"
direction="vertical"
dot
/>
<text class="hui-space__item">{{ active }} / {{ lastEvent }}</text>
</hui-space>
</view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { StepsItem } from '@nscode/handy-uni'
const lastEvent = ref('尚无事件 / No event')
const active = ref(0)
const onChange = (index: number, context: { item: StepsItem }) => {
lastEvent.value = JSON.stringify({ index, item: context.item })
}
const items = [
{ title: '提交 / Submit' },
{ title: '审核 / Review', description: '等待 / Waiting' },
{ title: '完成 / Done', disabled: true }
]
</script>
Props
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
items | StepsItem[] | [] | 条目数据。 |
active | number | — | 当前步骤下标,从 0 开始;v-model:active |
defaultActive | number | 0 | 非受控初始值 |
direction | StepsDirection | 'horizontal' | PC 同名 |
alignCenter | boolean | false | 横向时标题居中在图标下 |
finishStatus | StepsStatus | 'finish' | 已完成步骤的状态 |
processStatus | StepsStatus | 'process' | 当前步骤的状态 |
dot | boolean | false | 用小圆点代替序号 |
clickable | boolean | false | 点步骤切换;disabled 的项不响应 |
根节点类名和样式使用 customClass、customStyle。尺寸数字按 px,时长除明确说明外按 ms。
Events
| 事件 | 参数 |
|---|---|
update:active | (index: number) |
change | (index: number, context: { item: StepsItem }) |
受控状态由父级回写更新事件后改变。多词事件使用短横线。禁用操作、取消及过期异步结果不提交成功变更。
Slots
| 插槽 | 作用域 |
|---|---|
icon | { item, index, status } |
title | { item, index, status } |
description | { item, index, status } |
方法
无。
类型
StepsDirection、StepsStatus、StepsItem、StepsProps、StepsEmits.
平台说明
基于共享平台组件实现 H5、微信小程序、App-vue 与普通 Vue 3 Web。单元测试不代替设备验收;触摸、读屏、页面失活和原生组件表现按冒烟清单逐端核对。
设备冒烟清单.