Skip to content

Progress 進度條 ​

展示任務進度,支援狀態色、自訂顏色與文字格式化。

基礎用法 ​

vue
<template>
  <lh-progress :percentage="42" />
</template>

狀態 ​

vue
<template>
  <lh-progress :percentage="70" status="success" />
  <lh-progress :percentage="70" status="warning" />
  <lh-progress :percentage="70" status="exception" />
  <lh-progress :percentage="100" />
</template>

status 為 normal 且達到 100 時自動視為 success。

線寬與隱藏文字 ​

vue
<template>
  <lh-progress :percentage="60" :stroke-width="12" />
  <lh-progress :percentage="60" :show-text="false" />
</template>

自訂顏色 ​

字串直接作為條色,函式則按百分比傳回顏色。

vue
<template>
  <lh-progress :percentage="60" color="#C4A35A" />
  <lh-progress :percentage="60" :color="gradient" />
</template>

<script setup lang="ts">
const gradient = (p: number) => `rgb(${p}, 0, 0)`
</script>

自訂格式化與文字插槽 ​

vue
<template>
  <lh-progress :percentage="42" :format="format" />
  <lh-progress :percentage="42">
    <template #text="{ percentage }">
      <text>{{ percentage }} / 100</text>
    </template>
  </lh-progress>
</template>

<script setup lang="ts">
const format = (p: number) => `进度 ${p}`
</script>

Props ​

屬性說明類型預設值
percentage進度百分比 0-100(超出會自動鉗制)number0
type類型'line' | 'circle''line'
status狀態'normal' | 'success' | 'warning' | 'exception''normal'
color進度條顏色:字串或按百分比傳回顏色的函式string | ((percentage: number) => string)—
strokeWidth線條寬度 pxnumber6
width圓形模式畫布寬度 pxnumber126
showText是否顯示文字booleantrue
format自訂文字格式化(percentage: number) => string—
customClass自訂類別名string—
sx快速版面配置屬性LhSxProps—

Slots ​

插槽說明作用域參數
text自訂進度文字{ percentage: number }

circle 型暫未實作

小程序對 svg 支援有限,首版只實作 line 型。傳入 type="circle" 會按 line 渲染並在開發期告警一次(不靜默降級),circle 留待二期。