Skip to content

Progress进度条

Progress进度条用于展示操作的当前进度,适用于在操作耗时较长时,向用户呈现操作的进度与状态,尤其是当操作可能打断当前界面、后台运行且耗时超2秒,或者需要显示操作完成百分比的场景。

代码演示

  1. 进度条:标准进度条,可通过status属性设置不同状态,如active(激活)、exception(异常),还可通过show-info属性控制是否显示进度数值或状态图标。
30%
50%
vue

<template>
  <a-progress :percent="30" />
  <a-progress :percent="50" status="active" />
  <a-progress :percent="70" status="exception" />
  <a-progress :percent="100" />
  <a-progress :percent="50" :show-info="false" />
</template>
  1. 小型进度条:适用于狭窄区域,使用size="small"设置。
30%
50%
vue
<template>
  <div style="width: 170px">
    <a-progress :percent="30" size="small" />
    <a-progress :percent="50" size="small" status="active" />
    <a-progress :percent="70" size="small" status="exception" />
    <a-progress :percent="100" size="small" />
  </div>
</template>
  1. 响应式进度圈:当width小于等于20时,进度信息以Tooltip形式显示。
代码发布
vue
<template>
  <div>
    <a-progress
      type="circle"
      trail-color="#e6f4ff"
      :percent="60"
      :stroke-width="20"
      :size="12"
      :format="number => `进行中,已完成${number}%`"
    />
    <span :style="{ marginLeft: 8 }">代码发布</span>
  </div>
</template>

API

各类型共用的属性

属性说明类型默认值版本
format内容的模板函数function(percent, successPercent)(percent) => percent + %-
percent百分比number0-
showInfo是否显示进度数值或状态图标booleantrue-
status状态,可选successexceptionnormalactive(仅限line)string--
strokeColor进度条的色彩string--
strokeLinecap进度条的样式,可选roundbuttsquareroundbuttsquare
success成功进度条相关配置{ percent: number, strokeColor: string }--
titlehtml标签titlestring-3.0
trailColor未完成的分段的颜色string--
type类型,可选linecircledashboardstringline-
size进度条的尺寸number | [number, number] | "small" | "default""default"-

type="line"

属性说明类型默认值版本
steps进度条总共步数number--
strokeColor进度条的色彩,传入object时为渐变,有steps时支持传入数组string | string[] | { from: string; to: string; direction: string }--

type="circle"

属性说明类型默认值版本
strokeColor圆形进度条线的色彩,传入object时为渐变string | object--
strokeWidth圆形进度条线的宽度,单位是进度条画布宽度的百分比number6-

type="dashboard"

属性说明类型默认值版本
gapDegree仪表盘进度条缺口角度,可取值0 ~ 295number75-
gapPosition仪表盘进度条缺口位置topbottomleft
strokeWidth仪表盘进度条线的宽度,单位是进度条画布宽度的百分比number6-