Skip to content

CircleProgress 环形进度条

介绍

圆环形的进度条组件。

基础用法

html
<template>
  <nut-circle-progress :progress="20"></nut-circle-progress>
</template>

环形进度条自定义宽度

html
<template>
  <nut-circle-progress :progress="50" stroke-width="10"></nut-circle-progress>
</template>

环形进度条自定义颜色(支持渐变色)

html
<template>
  <nut-circle-progress :progress="50" custom-color="red"></nut-circle-progress>
  <nut-circle-progress :progress="100" :custom-color="gradientColor"></nut-circle-progress>
</template>
ts
const gradientColor = {
  "0%": "#ff5e5e",
  "100%": "#ffa062"
};

环形进度条自定义大小

html
<template>
  <nut-circle-progress :progress="50" radius="60"></nut-circle-progress>
</template>

环形进度条自定义内容

html
<template>
  <nut-circle-progress :progress="50">自定义</nut-circle-progress>
</template>

动态改变环形进度条的进度

html
<template>
  <nut-circle-progress :progress="progress"></nut-circle-progress>

  <nut-button @click="decrease()">减少</nut-button>
  <nut-button @click="increase()">增加</nut-button>
</template>
ts
const progress = ref(30);

function increase() {
  if (progress.value >= 100) {
    return;
  }

  progress.value = Math.min(100, progress.value + 10);
}

function decrease() {
  if (progress.value <= 0) {
    return;
  }

  progress.value = Math.max(0, progress.value - 10);
}

API

Props

参数说明类型可选值默认值
progress百分比number / string-0
stroke-width圆弧的宽度number / string-5
radius半径number / string-50
stroke-linecap圆环进度条端点形状stringbutt / round / squareround
custom-color圆环进度条颜色string / object-#ff673e
path-color圆环轨道颜色string-#d9d9d9
clockwise是否顺时针展示boolean-true

Slots

名称说明
default自定义文字内容

MIT Licensed