尺寸
<cu-progress :percentage="60" /> <cu-progress :percentage="60" size="sm" /> <cu-progress :percentage="60" size="xs" />
进度条用一条填充色带表示任务完成比例,支持线形三档粗细与自定义配色。
整目录放进工程即用:easycom 按标签逐个解析,页面写哪个组件就只编译哪个,不写 import,也没有全局注册这一步;单个组件也可以显式引入(第 4 步,可选);主题层在 App.uvue 引入一次即可。
# 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-progress /> # 4 单个组件也可以显式引入(可选,不用 easycom 时) import CuProgress from '@/uni_modules/colorui-x/components/cu-progress/cu-progress.uvue'
组件样式自包含(只依赖包内 token.scss),主题层是给页面工具类用的,不参与组件注册。两种安装方式见 快速上手。
| Android | iOS | HarmonyOS | Web(H5) | 微信小程序 | 支付宝小程序 |
|---|---|---|---|---|---|
| √ | — | — | √ | — | — |
Android 列取自本仓真机逐屏判定(√ 已验 / — 待复核 / × 已登记缺陷,本件当前为「真机已验」)。
Web 列只表示已编出可运行的预览产物,非真机渲染。
其余三端没有任何实测证据,不作支持承诺。
<cu-progress :percentage="60" /> <cu-progress :percentage="60" size="sm" /> <cu-progress :percentage="60" size="xs" />
<cu-progress :percentage="0" /> <cu-progress :percentage="5" /> <cu-progress :percentage="10" /> <cu-progress :percentage="50" activeColor="#e54d42" /> <cu-progress :percentage="100" activeColor="#0081ff" /> <cu-progress :percentage="-20" /> <cu-progress :percentage="130" />
<cu-progress :percentage="75" :showText="false" activeColor="#f37b1d" />
<cu-progress :percentage="40" activeColor="#9c26b0" inactiveColor="#ebd4ef" /> <cu-progress :percentage="80" activeColor="linear-gradient(to right, #f43f3b, #ec008c)" />
<view @tap="onStep"> <cu-progress :percentage="val" activeColor="#1cbbb4" /> </view>
这一节的交互由演示页脚本驱动,效果见右侧实时预览。
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| 进度 | |||
| percentage | 进度百分比 0 ~ 100,越界自动钳到两端 | Number | 0 |
| showText | 是否在填充条内显示百分比文字;不足 10% 时不出字 | Boolean | true |
| 配色 | |||
| activeColor | 填充条颜色;传渐变串时按背景图铺设,空串走内置色 | String | '' |
| inactiveColor | 轨道底色;空串走内置色 | String | '' |
| 尺寸与样式 | |||
| size | normal / sm / xs 三档轨道高度 | String | 'normal' |
| customStyle | 根节点内联样式 | Object | (): UTSJSONObject => ({}) |
| customClass | 追加到根节点的类名 | String | '' |
| 声明保留但不被消费 | |||
| url | 不产生跳转 | String | '' |
| linkType | 不产生跳转,同上 | String | 'navigateTo' |
本件不派发事件。
| slot | 说明 |
|---|---|
| (默认) | 填充条内的自定义内容;不填时显示百分比文字,showText 关闭或进度不足 10% 时留空 |
渐变看关键字 :填充色里只要出现渐变字样就按背景图铺设,其余一律当纯色;写渐变时关键字与色标要齐全,缺项会整条失效、只剩内置绿底。
粗细只有三档 :轨道高度只在三档之间切换,没有直接给数值的入口;要更粗或更细只能用 customStyle 覆盖根节点高度,条内文字字号不跟着变。