组件 / 导航 / cu-steps 步骤条

cu-steps

步骤条用于按顺序展示流程进度,支持横向与纵向两种排列。

已知缺口
01 / Install

引入组件

整目录放进工程即用:easycom 按标签逐个解析,页面写哪个组件就只编译哪个,不写 import,也没有全局注册这一步;单个组件也可以显式引入(第 4 步,可选);主题层在 App.uvue 引入一次即可。

install
# 1  整目录放进工程(easycom 自动解析)
your-project/
└── uni_modules/
    └── colorui-x/

# 2  App.uvue 全局引入主题层(一次)
@import 'uni_modules/colorui-x/theme/base.css';
@import 'uni_modules/colorui-x/theme/layout.css';
@import 'uni_modules/colorui-x/theme/color.scss';  // 颜色工具类(.bg-* / .text-*)

# 3  页面里直接用,不写 import(只编译用到的组件)
<cu-steps />

# 4  单个组件也可以显式引入(可选,不用 easycom 时)
import CuSteps from '@/uni_modules/colorui-x/components/cu-steps/cu-steps.uvue'

组件样式自包含(只依赖包内 token.scss),主题层是给页面工具类用的,不参与组件注册。两种安装方式见 快速上手。

02 / Platform

平台支持

AndroidiOSHarmonyOSWeb(H5)微信小程序支付宝小程序
√ — — √ — —

Android 列取自本仓真机逐屏判定(√ 已验 / — 待复核 / × 已登记缺陷,本件当前为「真机已验」)。

Web 列只表示已编出可运行的预览产物,非真机渲染。

其余三端没有任何实测证据,不作支持承诺。

03 / Demo

代码演示

01

默认

uvue
<cu-steps :current="0">
  <cu-steps-item :current="0" :index="0" :total="3" title="已出库" desc="10:35" />
  <cu-steps-item :current="0" :index="1" :total="3" title="运输中" desc="12:00" />
  <cu-steps-item :current="0" :index="2" :total="3" title="已签收" desc="18:20" />
</cu-steps>
02

当前项

uvue
<cu-steps v-for="(c, ci) in currents" :key="ci" :current="c">
  <cu-steps-item v-for="(t, ti) in fourTitles" :key="ti" :current="c" :index="ti" :total="4" :title="t" />
</cu-steps>
03

圆点

uvue
<cu-steps :current="1" :dot="true">
  <cu-steps-item :current="1" :index="0" :total="4" :dot="true" title="下单" />
  <cu-steps-item :current="1" :index="1" :total="4" :dot="true" title="付款" />
  <cu-steps-item :current="1" :index="2" :total="4" :dot="true" title="发货" />
  <cu-steps-item :current="1" :index="3" :total="4" :dot="true" title="签收" />
</cu-steps>
04

颜色

uvue
<cu-steps :current="2" activeColor="#39b54a" inactiveColor="#e7ebed">
  <cu-steps-item :current="2" :index="0" :total="3" activeColor="#39b54a" inactiveColor="#e7ebed" title="绿档 1" />
  <cu-steps-item :current="2" :index="1" :total="3" activeColor="#39b54a" inactiveColor="#e7ebed" title="绿档 2" />
  <cu-steps-item :current="2" :index="2" :total="3" activeColor="#39b54a" inactiveColor="#e7ebed" title="绿档 3" />
</cu-steps>
<cu-steps :current="1" activeColor="" inactiveColor="">
  <cu-steps-item :current="1" :index="0" :total="3" activeColor="" inactiveColor="" title="两色都传空串 1" />
  <cu-steps-item :current="1" :index="1" :total="3" activeColor="" inactiveColor="" title="两色都传空串 2" />
  <cu-steps-item :current="1" :index="2" :total="3" activeColor="" inactiveColor="" title="两色都传空串 3" />
</cu-steps>
05

图标

uvue
<cu-steps :current="1" activeIcon="cuIcon-check" inactiveIcon="cuIcon-close">
  <cu-steps-item :current="1" :index="0" :total="3" activeIcon="cuIcon-check" inactiveIcon="cuIcon-close" title="图标档 1" />
  <cu-steps-item :current="1" :index="1" :total="3" activeIcon="cuIcon-check" inactiveIcon="cuIcon-close" title="图标档 2" />
  <cu-steps-item :current="1" :index="2" :total="3" activeIcon="cuIcon-check" inactiveIcon="cuIcon-close" title="图标档 3" />
</cu-steps>
06

失败态

uvue
<cu-steps :current="2">
  <cu-steps-item :current="2" :index="0" :total="4" title="完成" :error="false" />
  <cu-steps-item :current="2" :index="1" :total="4" title="失败" :error="true" />
  <cu-steps-item :current="2" :index="2" :total="4" title="当前" :error="false" />
  <cu-steps-item :current="2" :index="3" :total="4" title="未到" :error="false" />
</cu-steps>
<cu-steps :current="2" :dot="true">
  <cu-steps-item :current="2" :index="0" :total="3" :dot="true" title="点态完成" />
  <cu-steps-item :current="2" :index="1" :total="3" :dot="true" :error="true" title="点态失败" />
  <cu-steps-item :current="2" :index="2" :total="3" :dot="true" title="点态当前" />
</cu-steps>
07

竖向

uvue
<cu-steps direction="column" :current="1">
  <cu-steps-item direction="column" :current="1" :index="0" :total="4" title="提交申请" desc="已通过" />
  <cu-steps-item direction="column" :current="1" :index="1" :total="4" title="资质审核" desc="审核中,这一项的说明文字故意写得很长,用来看竖向档文案区是否吃掉右侧剩余宽度并把后段连接线拉满" />
  <cu-steps-item direction="column" :current="1" :index="2" :total="4" title="开户" />
  <cu-steps-item direction="column" :current="1" :index="3" :total="4" title="寄卡" desc="" />
</cu-steps>
<cu-steps direction="column" :current="1" :dot="true">
  <cu-steps-item direction="column" :current="1" :index="0" :total="3" :dot="true" title="竖向点态 1" />
  <cu-steps-item direction="column" :current="1" :index="1" :total="3" :dot="true" title="竖向点态 2" />
  <cu-steps-item direction="column" :current="1" :index="2" :total="3" :dot="true" title="竖向点态 3" />
</cu-steps>
08

文案 / 图标尺寸

uvue
<cu-steps :current="0" activeIcon="cuIcon-appreciate">
  <cu-steps-item :current="0" :index="0" :total="3" activeIcon="cuIcon-appreciate" :iconSize="12" title="iconSize=12 → 24rpx" desc="小号" />
</cu-steps>
<cu-steps :current="1">
  <cu-steps-item :current="1" :index="0" :total="3" title="只有标题" />
  <cu-steps-item :current="1" :index="1" :total="3" title="标题+描述" desc="10:35" />
  <cu-steps-item :current="1" :index="2" :total="3" title="描述给空串(应只剩标题)" desc="" />
</cu-steps>
<cu-steps :current="1">
  <cu-steps-item :current="1" :index="0" :total="2" title="标题超长对照文案用来观察 row 档文案是否溢出到相邻格" desc="描述也很长长长长长长长长长长" />
  <cu-steps-item :current="1" :index="1" :total="2" title="第二项" />
</cu-steps>
09

插槽

uvue
<cu-steps :current="1">
  <cu-steps-item :current="1" :index="0" :total="3" title="icon 槽自绘">
    <template v-slot:icon>
      <text>
        A
      </text>
    </template>
    <template v-slot:desc>
      <text>
        槽里的描述文案
      </text>
    </template>
  </cu-steps-item>
  <cu-steps-item :current="1" :index="1" :total="3" title="默认兜底" desc="走 props 档" />
  <cu-steps-item :current="1" :index="2" :total="3" title="只覆盖 desc 槽">
    <template v-slot:desc>
      <text>
        只有描述是槽
      </text>
    </template>
  </cu-steps-item>
</cu-steps>
10

总步数缺省

uvue
<cu-steps :current="1">
  <cu-steps-item :current="1" :index="0" title="无 total 1" />
  <cu-steps-item :current="1" :index="1" title="无 total 2" />
</cu-steps>
11

自定义样式

uvue
<cu-steps :current="0" :customStyle="stepsStyle" customClass="custom-class">
  <cu-steps-item :current="0" :index="0" :total="2" customClass="custom-class" title="子件带页侧类" />
  <cu-steps-item :current="0" :index="1" :total="2" title="对照" />
</cu-steps>
12

取值与事件

这一节的交互由演示页脚本驱动,效果见右侧实时预览。

04 / Props · Events · Slots

全量 API

props

参数说明类型默认值
方向与样式
directionrow / column,步骤条方向;其余取值按横向渲染String'row'
customStyle根节点内联样式Object(): UTSJSONObject => ({})
customClass追加到根节点的类名String''
声明保留但不被消费
current当前步序号;容器不读取,须同时传给每个 cu-steps-itemNumber0
activeColor已完成段与当前步的颜色;容器不读取,须同时传给子项,空串时走内置蓝色档String''
inactiveColor未到达段的颜色;容器不读取,须同时传给子项,空串时走内置灰色档String''
activeIcon已完成步与当前步的图标名;容器不读取,须同时传给子项String''
inactiveIcon未到达步的图标名;容器不读取,须同时传给子项String''
dot是否用小圆点代替序号;容器不读取,须同时传给子项Booleanfalse
url不产生跳转,传参不生效String''
linkType不产生跳转,同上String'navigateTo'

events

本件不派发事件。

slots

slot说明
(默认)逐个放入 cu-steps-item;不填时容器为空
05 / Notes

注意事项

下标全靠手传 :子项不会自动编号,index 与 total 都要逐项手写;漏传序号时全部按 0 计算,整条会被判成同一步。

末段线不裁 :不传总数时不会裁掉最后一项的右侧连接线,末尾会多画一段线;把 total 传成实际步数才能收干净。