Skip to content

LineProgress 线形进度条

用于任务进度、上传进度、步骤完成度和仪表盘进度展示等场景。

平台差异说明

App(vue)App(nvue)H5小程序

基本使用

  • 通过 percentage 设置进度百分比(0–100)。
html
<see-line-progress :percentage="50" />

进度状态

  • 通过 status 设置进度条状态,支持 normalsuccesswarningerror
html
<see-line-progress :percentage="50" status="normal" />
<see-line-progress :percentage="100" status="success" />
<see-line-progress :percentage="80" status="warning" />
<see-line-progress :percentage="30" status="error" />

自定义颜色

  • 通过 activeColor 自定义激活部分颜色,支持单色和渐变色。
html
<!-- 单色 -->
<see-line-progress :percentage="60" activeColor="#ff6b6b" />

<!-- 渐变色 -->
<see-line-progress :percentage="80" :activeColor="['#43e97b', '#38f9d7']" />

条纹与动画

  • 通过 striped 显示条纹效果。
  • 通过 animated 开启条纹动画。
html
<see-line-progress :percentage="60" striped />
<see-line-progress :percentage="80" striped animated />

进度条尺寸

  • 通过 strokeWidth 设置进度条高度。
html
<see-line-progress :percentage="50" strokeWidth="8rpx" />
<see-line-progress :percentage="50" strokeWidth="24rpx" />

文字位置

  • 默认文字显示在进度条右侧。
  • 设置 textInsidetrue 可将文字显示在进度条内部。
  • 设置 showTextfalse 可隐藏文字。
html
<!-- 外部文字(默认) -->
<see-line-progress :percentage="50" />

<!-- 内部文字 -->
<see-line-progress :percentage="60" textInside strokeWidth="32rpx" />

<!-- 隐藏文字 -->
<see-line-progress :percentage="70" :showText="false" />

自定义文字

  • 通过 format 函数自定义显示文字。
html
<see-line-progress :percentage="50" :format="formatText" />

<script lang="ts" setup>
const formatText = (percentage: number) => {
  return percentage === 100 ? '完成' : `${percentage}%`
}
</script>

圆角与禁用

  • 设置 roundfalse 可关闭圆角,默认为 true
  • 设置 inactivetrue 可显示禁用状态。
html
<see-line-progress :percentage="50" :round="false" />
<see-line-progress :percentage="50" inactive />

自定义轨道颜色

  • 通过 trackColor 自定义轨道背景颜色。
html
<see-line-progress :percentage="50" trackColor="#e8e8e8" />

最大值

  • 通过 max 设置最大值,默认为 100
  • percentage 会按 max 自动换算为百分比。
html
<!-- 总数 200,当前 150,显示 75% -->
<see-line-progress :percentage="150" :max="200" />

API

Props

参数名说明类型默认值可选值平台差异
percentage进度值Number0任意数字-
max最大值Number100任意正数-
strokeWidth进度条高度String'16rpx'任意 CSS 长度值-
trackColor轨道背景颜色String'var(--see-fill-color-light, #f2f3f5)'任意 CSS 颜色值-
activeColor激活部分颜色String / Array''(使用 status 对应颜色)CSS 颜色值或颜色数组-
status进度条状态'normal' | 'success' | 'warning' | 'error''normal'normalsuccesswarningerror-
striped是否显示条纹Booleanfalsetruefalse-
animated是否开启条纹动画Booleanfalsetruefalse-
showText是否显示文字Booleantruetruefalse-
textInside文字是否显示在进度条内部Booleanfalsetruefalse-
format自定义文字格式化函数(percentage: number) => stringundefined任意格式化函数-
round是否圆角Booleantruetruefalse-
inactive是否禁用状态Booleanfalsetruefalse-
duration过渡动画时长(毫秒)Number300任意正整数-

Events

事件名说明回调参数平台差异
onChange进度值变化时触发percentage: number-
onComplete进度达到 100% 时触发-

Slots

插槽名说明作用域数据
text自定义文字内容{ percentage }

辽 ICP 备 2025070134 号