CircleProgress 进度环
环形进度组件:canvas 2d 绘制轨道圆与进度弧(drawCircleTrack / drawCircleArc, share core 收口,web 与小程序同构),文字用绝对定位 view 覆盖在画布上。 服务任务进度、加载占比、评分占比等场景。
平台差异(登记):本端为 canvas 2d 形态——小程序模板不支持 SVG (share circle-progress styles 的 SVG 形态面向 web 端),本端用
<canvas type="2d">消费同一份 share core 绘制纯函数;几何(半径 / 扫角 / 逆时针换算)与颜色归一、文案格式化全部复用 share core,端内只做 canvas 取上下文与重绘调度。组件无事件、纯受控。
基础用法
vue
<template>
<lh-circle-progress :model-value="40" />
<lh-circle-progress :model-value="70" :size="140" :stroke-width="12" />
</template>自定义颜色与渐变
color 支持单色字符串或色数组;数组 ≥2 项时按数组顺序作线性渐变端点。 trackColor 未传时取轨道令牌的兜底色:
vue
<lh-circle-progress :model-value="70" color="#B87800" track-color="#F0EBE2" />
<lh-circle-progress :model-value="80" :color="['#2B4C7C', '#C4A35A']" />
<lh-circle-progress :model-value="80" :color="['#5B8C5A', '#C4A35A', '#B23A3A']" />逆时针与起始角度
clockwise 默认 true(顺时针);startAngle 以 12 点钟方向为 0 度、 顺时针为正:
vue
<lh-circle-progress :model-value="55" :clockwise="false" />
<lh-circle-progress :model-value="55" :start-angle="90" />
<lh-circle-progress :model-value="55" :start-angle="135" :clockwise="false" />自定义文案
默认文案为取整百分号;format 覆盖格式化,默认 slot 覆盖整段文案, showText=false 关闭文案(根节点追加 lh-circle-progress--no-text):
vue
<lh-circle-progress :model-value="42" :format="(v: number) => `${v} 分`" />
<lh-circle-progress :model-value="100">完成</lh-circle-progress>
<lh-circle-progress :model-value="30" :show-text="false" />Props
| 属性 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| modelValue | 进度百分比 0-100(受控,超出自动钳制) | number | 0 |
| size | 环尺寸 px(直径,canvas 画布宽高) | number | 120 |
| strokeWidth | 描边宽度 px | number | 6 |
| color | 进度色:单色或渐变色数组(≥2 项作线性渐变端点) | string | string[] | 主题色兜底 |
| trackColor | 轨道色(未传取令牌兜底色) | string | 禁用色兜底 |
| clockwise | 顺时针(false 为逆时针描画) | boolean | true |
| startAngle | 起始角度(度,0 = 12 点钟方向,顺时针为正) | number | 0 |
| showText | 展示默认百分比文案 | boolean | true |
| format | 文案格式化(默认取整百分号) | (v: number) => string | — |
| linecap | 描边端点形状 | 'butt' | 'round' | 'square' | 'round' |
| label | 无障碍可达名称 | string | — |
| customClass | 自定义类名(透传到根节点) | string | — |
| sx | sx 快速布局属性 | LhSxProps | — |
无障碍
根节点携带 role="progressbar" 与 aria-valuemin/max/now 值域语义; label 提供可达名称(如「上传进度」),modelValue 超出 0-100 时先钳制再播报。

