May 07, 2021 Vant
import Vue from 'vue';
import { Circle } from 'vant';
Vue.use(Circle);
The rate property represents the target progress of the progress bar, and v-model represents the real-time progress during the animation. When the rate changes, the v-model changes at the speed of the speed of the rate until the rate-set value is reached.
<van-circle
v-model="currentRate"
:rate="30"
:speed="100"
:text="text"
/>
export default {
data() {
return {
currentRate: 0
};
},
computed: {
text() {
return this.currentRate.toFixed(0) + '%'
}
}
};
The width of the progress bar is controlled by thestroke-width property
<van-circle
v-model="currentRate"
:rate="rate"
:stroke-width="60"
text="宽度定制"
/>
The color bar color is controlled by the color property, and the layer-color property is used to control the track color
<van-circle
v-model="currentRate"
:rate="rate"
layer-color="#ebedf0"
text="颜色定制"
/>
The color property supports the incoming object format to define the gradient color
<van-circle
v-model="currentRate"
:rate="rate"
:color="gradientColor"
text="渐变色"
/>
export default {
data() {
return {
currentRate: 0,
gradientColor: {
'0%': '#3fecff',
'100%': '#6149f6'
}
};
}
};
Set lockwise to false, and progress starts counterclockwise
<van-circle
v-model="currentRate"
:rate="rate"
:clockwise="false"
text="逆时针方向"
/>
Set the ring diameter with the size property
<van-circle
v-model="currentRate"
:rate="rate"
size="120px"
text="大小定制"
/>
Parameters | Description | Type | The default |
---|---|---|---|
v-model | The current progress | number | - |
rate | Target progress | number | string |
100
|
size |
Doughn emoon diameter, the default
px
|
number | string |
100px
|
color
v2.1.4
|
Progress bar color, the incoming object format can define a gradient color | string | object |
#1989fa
|
layer-color | Track color | string |
white
|
fill | Fill color | string |
none
|
speed | Animation speed (rate/s) | number | string |
0
|
text | Text | string | - |
stroke-width | The width of the progress bar | number | string |
40
|
stroke-linecap
v2.2.15
|
The shape of the progress bar endpoint, with an
sqaure
butt
|
string |
round
|
clockwise | Whether to increase clockwise | boolean |
true
|
Name | Description |
---|---|
default | Customize the text content |