Skip to content

引入组件

局部引入

ts
const FCircularProgress = defineAsyncComponent(
  () => import('@/components/formaui/f-circular-progress/f-circular-progress.vue')
)

基础用法

percentage属性:进度百分比(10% 传 10

html
<f-circular-progress :percentage="70" />
html
<f-circular-progress active-color="#EB0909" font-color="#EB0909" :percentage="70" />

isTextShow属性:是否显示进度文字(默认true

html
<f-circular-progress :is-text-show="false" :percentage="50" />

text属性:自定义中心文字

html
<f-circular-progress text="拼团" active-color="#EB0909" :percentage="80" />

showTrack / trackColor属性:背景轨道

html
<f-circular-progress track-color="rgba(255,121,0,0.1)" active-color="#ff7900" :percentage="50" />

gradientColor属性:渐变结束色

html
<f-circular-progress :show-track="false" active-color="#ff7900" gradient-color="#5677fc" :percentage="80" />

diameter / lineWidth / fontSize属性:尺寸(单位 px)

html
<f-circular-progress :percentage="60" :diameter="80" :font-size="16" />
<f-circular-progress :percentage="60" :diameter="100" :line-width="10" :font-size="20" />

isCounterclockwise / activeMode属性:逆时针与动画续播

html
<f-circular-progress :percentage="progress" is-counterclockwise active-mode="forwards" />

半圆进度:heightstartAngle 与插槽

html
<f-circular-progress
  :is-text-show="false"
  :percentage="40"
  :start-angle="-Math.PI"
  :diameter="240"
  :height="130"
  :line-width="12"
  @change="onChange">
  <view>自定义内容 {{ progress }}%</view>
</f-circular-progress>

插槽

名称说明
default自定义中心区域内容,覆盖默认百分比文字

属性

属性名类型说明默认值
diameternumber画布直径(px)60
heightnumber画布高度,半弧时使用(px)0(取 diameter)
lineWidthnumber线宽(px)4
lineCap'butt' | 'round' | 'square'线条端点'round'
fontSizenumber文字大小(px)12
fontColorstring文字颜色主题色
isTextShowboolean是否显示进度文字true
textstring自定义文字,空则显示百分比''
showTrackboolean是否显示背景轨道true
trackColorstring背景轨道颜色#CCCCCC
activeColorstring进度条颜色主题色
gradientColorstring渐变结束色''
startAnglenumber起始弧度-π/2
isCounterclockwiseboolean是否逆时针false
percentagenumber进度 0~1000
multiplenumber百分比缩放倍数1
durationnumber动画时长(ms)800
activeMode'backwards' | 'forwards'动画模式'backwards'

事件

事件名说明回调参数
change进度变化{ percentage: number }
end动画结束{ canvasId: string, percentage: number }