# Progress 進度條

任務進度視覺化。線形與環形兩種形態,支援狀態配色、自訂顏色函式與文字格式化。

進度條
<template>
  <div class="demo-col">
    <p class="demo-note">line 線形</p>
    <LhProgress :percentage="30" />
    <LhProgress :percentage="70" status="success" />
    <LhProgress :percentage="45" status="warning" />
    <LhProgress :percentage="20" status="danger" />
    <LhProgress :percentage="60" :stroke-width="20" :format="fmt" />
    <LhProgress :percentage="100" :show-text="false" />
    <p class="demo-note">circle 環形(width 控制畫布尺寸,strokeWidth 控制描邊)</p>
    <div class="demo-row" style="gap: 32px; flex-wrap: wrap">
      <LhProgress type="circle" :percentage="75" />
      <LhProgress type="circle" :percentage="40" :width="120" :stroke-width="14" status="warning" />
      <LhProgress type="circle" :percentage="100" status="success" :format="fmt" />
    </div>
    <p class="demo-note">color 字串或按百分比回傳顏色的函式</p>
    <LhProgress :percentage="percent" :color="colorFn" />
    <LhButton size="small" @click="bump">{{ percent >= 100 ? '重設' : '+10' }}</LhButton>
  </div>
</template>

<script>
export default {
  data: () => ({
    percent: 30,
  }),
  methods: {
    fmt(p) {
      return `${p / 10} 成`
    },
    colorFn(p) {
      if (p < 40) return 'var(--lh-danger-color)'
      if (p < 80) return 'var(--lh-warning-color)'
      return 'var(--lh-success-color)'
    },
    bump() {
      this.percent = this.percent >= 100 ? 0 : this.percent + 10
    },
  },
}
</script>

# Props

屬性 說明 類型 預設值
percentage 進度百分比 0-100(超出會自動鉗制) number —
type 類型 'line' \| 'circle' 'line'
status 狀態配色 'default' \| 'success' \| 'warning' \| 'danger' 'default'
color 進度條顏色:字串或按百分比回傳顏色的函式 string \| ((percentage: number) => string) —
strokeWidth 線條寬度 px(line 為高度,circle 為描邊寬度) number —
width 圓形模式畫布寬度 px number —
showText 是否展示進度文字 boolean true
format 自訂文字格式化 (percentage: number) => string —
sx sx 快速佈局屬性 — —

Copyright © 2024-2026 风默文学 | 宁ICP备2024006574号 | 公安备案徽标苏公网安备32040002010537