Vant 中文入门教程 Vant Progress 进度条

2024-02-25 开发教程 Vant 中文入门教程 匿名 0

引入

import Vue from 'vue';
import { Progress } from 'vant';
Vue.use(Progress);

代码演示

基础用法

进度条默认为蓝色,使用percentage属性来设置当前进度

<van-progress :percentage="50" />

线条粗细

通过stroke-width可以设置进度条的粗细

<van-progress :percentage="50" stroke-width="8" />

置灰

设置inactive属性后进度条将置灰

<van-progress inactive :percentage="50" />

样式定制

可以使用pivot-text属性自定义文字,color属性自定义进度条颜色

<van-progress
pivot-text="橙色"
color="#f2826a"
:percentage="25"
/>
<van-progress
pivot-text="红色"
color="#ee0a24"
:percentage="50"
/>
<van-progress
:percentage="75"
pivot-text="紫色"
pivot-color="#7232dd"
color="linear-gradient(to right, #be99ff, #7232dd)"
/>

API

Props

参数说明类型默认值
percentage进度百分比number | string0
stroke-width v2.2.1进度条粗细,默认单位为pxnumber | string4px
color进度条颜色string#1989fa
track-color v2.2.9轨道颜色string#e5e5e5
pivot-text进度文字内容string百分比
pivot-color进度文字背景色string同进度条颜色
text-color进度文字颜色stringwhite
inactive是否置灰booleanfalse
show-pivot是否显示进度文字booleantrue

实例演示