Skip to content

Steps 步骤条组件

该组件一般用于完成一个任务要分几个步骤,标识目前处于第几步的场景。

温馨提示

本项目参考了 uView-Plus 开源项目的组件开发方式,基于 Vue 3 和 TypeScript 实现了自定义组件。目前该组件仍处于测试阶段。
感谢 uView-Plus 开源项目及其团队成员的贡献,他们的组件开发思路为本项目提供了宝贵地参考。如果需要了解更多组件开发细节,可以参考uView-Plus的 steps组件 的代码实现。

平台差异说明

APP(vue)H5微信小程序

基本使用示例

html
<!-- 全局使用 -->
<hy-steps :list="list"></hy-steps>
<!-- 单个组件引入 -->
<HySteps :list="list"></HySteps>
ts
import { HySteps } from "hy-app";
const list = ref([
    {title: "已下单", desc: "2024-10-13",},
    {title: "已发货", desc: "2024-10-13",},
    {title: "发货失败", desc: "2024-10-14", error: true},
])

步骤条模式

  • 设置dot参数为true的话,将会以点状的形式展示步骤条样式。
html
<template>
    <hy-steps :list="list" dot></hy-steps>
</template>

竖向模式

  • 设置direction参数为为column的话,组件将会以竖向的形式展示步骤条内容。
html
<template>
    <!--横向-->
    <hy-steps :list="list" direction="row"></hy-steps>
    <!--竖向-->
    <hy-steps :list="list" direction="column"></hy-steps>
</template>

自定义图标

  • 通过activeIcon可以设置激活状态的图标
  • 通过inactiveIcon可以设置非激活状态的图标
html
<template>
    <hy-steps :list="list" :activeIcon="IconConfig.MAP" :inactiveIcon="IconConfig.LOADING"></hy-steps>
</template>

<script setup>
  import { IconConfig } from "hy-app";
</script>

通过插槽自定义右边内容

  • 设置dot参数为true的话,将会以点状的形式展示步骤条样式。
html
<template>
    <hy-steps :list="list">
        <template #content="{ record }">
            {{record}}
        </template>
    </hy-steps>
</template>

API

参数说明类型默认值
list步骤条数据集合array-
current设置当前处于第几步number0
directionrow-横向,column-竖向row | columnrow
activeColor激活状态颜色string#3c9cff
inactiveColor未激活状态颜色string#969799
activeIcon激活状态的图标string-
inactiveIcon未激活状态图标string-
dot是否显示点类型booleanfalse
iconSize图标大小string | number17
customStyle定义需要用到的外部样式CSSProperties-

list

参数说明类型默认值
title标题string-
desc描述string-
error是否错误boolean-

Events

事件名说明回调参数
click--

Slots

插槽名说明接收值
icon自定义步骤左侧iconindex: 当前索引,error: 接收是否错误信息
content自定步骤右侧整体内容item: 整体内容, index: 当前索引
title自定步骤右侧标题内容title: 标题内容, index: 当前索引
desc自定步骤右侧描述desc: 描述内容,index: 当前索引
00:46