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 は第二期に回します。