mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-09 08:48:58 +08:00
2.6 KiB
2.6 KiB
Circle
Install
import Vue from 'vue';
import { Circle } from 'vant';
Vue.use(Circle);
Usage
Basic Usage
<van-circle v-model="currentRate" :rate="30" :speed="100" :text="text" />
export default {
data() {
return {
currentRate: 0,
};
},
computed: {
text() {
return this.currentRate.toFixed(0) + '%';
},
},
};
Custom Width
<van-circle
v-model="currentRate"
:rate="rate"
:stroke-width="60"
text="Custom Width"
/>
Custom Color
<van-circle
v-model="currentRate"
:rate="rate"
layer-color="#ebedf0"
text="Custom Color"
/>
Gradient
<van-circle
v-model="currentRate"
:rate="rate"
:color="gradientColor"
text="Gradient"
/>
export default {
data() {
return {
currentRate: 0,
gradientColor: {
'0%': '#3fecff',
'100%': '#6149f6',
},
};
},
};
Counter Clockwise
<van-circle
v-model="currentRate"
:rate="rate"
:clockwise="false"
text="Counter Clockwise"
/>
Custom Size
<van-circle
v-model="currentRate"
:rate="rate"
size="120px"
text="Custom Size"
/>
API
Props
Attribute | Description | Type | Default |
---|---|---|---|
v-model | Current rate | number | - |
rate | Target rate | number | string | 100 |
size | Circle size | number | string | 100px |
color | Progress color, passing object to render gradient | string | object | #1989fa |
layer-color | Layer color | string | white |
fill | Fill color | string | none |
speed | Animate speed(rate/s) | number | string | 0 |
text | Text | string | - |
stroke-width | Stroke width | number | string | 40 |
stroke-linecap | Stroke linecap,can be set to sqaure butt |
string | round |
clockwise | Whether to be clockwise | boolean | true |
Slots
Name | Description |
---|---|
default | custom text content |
Less Variables
How to use: Custom Theme.
Name | Default Value | Description |
---|---|---|
@circle-size | 100px |
- |
@circle-color | @blue |
- |
@circle-layer-color | @white |
- |
@circle-text-color | @text-color |
- |
@circle-text-font-weight | @font-weight-bold |
- |
@circle-text-font-size | @font-size-md |
- |
@circle-text-line-height | @line-height-md |
- |