Skip to content

Progress 进度条

介绍

用于展示操作的当前进度。

导入

js
import Progress from '@/components/display/Progress.vue'

使用方法

基础用法

基础的水平进度条,支持多种颜色。

vue
<template>
  <FlexCol :gap="20">
    <Progress :value="progress" />
    <Progress progressColor="success" :value="progress" />
    <Progress progressColor="warning" :value="progress" />
    <Progress progressColor="danger" :value="progress" />
  </FlexCol>
</template>

<script setup lang="ts">
import { ref } from 'vue';

const progress = ref(50);
</script>

从右到左的进度条

通过设置 type 属性为 right-left 可以创建从右到左的进度条。

vue
<template>
  <Progress type="right-left" :value="progress" />
</template>

<script setup lang="ts">
import { ref } from 'vue';

const progress = ref(50);
</script>

调整线条粗细

通过 height 属性可以调整进度条的粗细。

vue
<template>
  <Progress :value="progress" :height="20" />
</template>

<script setup lang="ts">
import { ref } from 'vue';

const progress = ref(50);
</script>

显示进度文字

通过设置 showProgressText 属性为 true 显示进度百分比文字。

vue
<template>
  <FlexCol :gap="50">
    <Progress :value="progress" showProgressText />
    <Progress :value="progress" type="right-left" showProgressText />
    <Progress :value="progress" showProgressText progressPos="left" />
    <Progress :value="progress" showProgressText progressPos="right" />
  </FlexCol>
</template>

<script setup lang="ts">
import { ref } from 'vue';

const progress = ref(50);
</script>

竖向进度条

通过设置 type 属性为 top-bottombottom-top 可以创建竖向进度条。

vue
<template>
  <FlexRow :gap="60">
    <FlexRow :gap="20" :height="300">
      <Progress type="top-bottom" :value="progress" />
      <Progress type="top-bottom" progressColor="success" :value="progress" />
      <Progress type="bottom-top" progressColor="warning" :value="progress" />
      <Progress type="bottom-top" progressColor="danger" :value="progress" />
    </FlexRow>
    <FlexRow :gap="50" :height="300">
      <Progress type="top-bottom" :value="progress" showProgressText />
      <Progress type="bottom-top" showProgressText :value="progress" />
    </FlexRow>
  </FlexRow>
</template>

<script setup lang="ts">
import { ref } from 'vue';

const progress = ref(50);
</script>

有动画效果的进度条

通过设置 animate 属性为 true 可以为进度条添加过渡动画效果。

vue
<template>
  <FlexCol :gap="20">
    <FlexCol :gap="50">
      <Progress animate :value="progress" />
      <Progress animate :value="progress" showProgressText />
    </FlexCol>
    <FlexRow :gap="20">
      <Button @click="progress -= 10">- 减少</Button>
      <Button @click="progress += 10">+ 增加</Button>
    </FlexRow>
  </FlexCol>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import Button from '@/components/basic/Button.vue';

const progress = ref(50);
</script>

API 参考

Progress

进度条组件。

Props

名称说明类型必填默认值
value当前进度,0-100number0
backgroundColor背景的颜色string-'gray'
progressColor进度的颜色string-'primary'
progressPos进度文字的位置。center 居中;right 居右;flow 跟随进度'left' | 'right' | 'flow'-'flow'
progressTextStyle进度文字的自定义样式TextStyle--
progressStyle进度的样式ViewStyle--
type进度条的方向
* left-right 横向,从左到右
* right-left 横向,从右到左
* top-bottom 竖向,从上到下
* bottom-top 竖向,从下到上
'left-right' | 'right-left' | 'top-bottom' | 'bottom-top'-'left-right'
height进度条的高度,竖向模式时自动设置为高度number-15
width进度条宽度,默认100%沾满父容器number | string-'100%'
showProgressText是否显示进度文字boolean-false
innerStyle背景样式ViewStyle--
round是否是圆角boolean-true
radiusround=true 时的圆角大小number-20
animate是否有动画效果boolean-false
animateDuration动画效果时长,msnumber-300

Events

名称说明参数
click点击事件$event

主题变量

名称类型默认值说明
ProgressBackgroundColorstring'gray'背景颜色
ProgressProgressColorstring'primary'进度颜色
ProgressTypestring'left-right'进度条方向
ProgressHeightnumber15进度条高度
ProgressWidthstring'100%'进度条宽度
ProgressShowProgressTextbooleanfalse是否显示进度文字
ProgressProgressPosstring'flow'进度文字位置
ProgressRoundbooleantrue是否是圆角
ProgressRadiusnumber20圆角大小
ProgressAnimatebooleanfalse是否有动画效果
ProgressAnimateDurationnumber300动画时长(ms)
ProgressTextWidthnumber80进度文字宽度
ProgressTextAlignstring'center'进度文字对齐方式
ProgressTextPaddingVerticalnumber2进度文字垂直内边距
ProgressTextPaddingHorizontalnumber2进度文字水平内边距
ProgressTextBorderRadiusnumber20进度文字圆角半径
ProgressTextFontSizenumber24进度文字字体大小
ProgressTextColorstring'white'进度文字颜色
ProgressTextSingleColorstring'text.content'单独显示的进度文字颜色