Slider
Install
import { Slider } from 'vant';
Vue.use(Slider);
Usage
Basic Usage
<van-slider v-model="value" @change="onChange" />
export default {
data() {
return {
value: 50
};
},
methods: {
onChange(value) {
this.$toast('Current value:' + value);
}
}
};
Range
<van-slider v-model="value" :min="10" :max="90" />
Disabled
<van-slider v-model="value" disabled />
Step size
<van-slider v-model="value" :step="10" />
Custom style
<van-slider
v-model="value"
bar-height="4px"
active-color="#f44"
/>
Custom button
<van-slider
v-model="value"
active-color="#f44"
>
<div
slot="button"
class="custom-button"
>
{{ value }}
</div>
</van-slider>
Vertical
<div :style="{ height: '100px' }">
<van-slider v-model="value" vertical />
</div>
API
| Attribute |
Description |
Type |
Default |
|
| value |
Current value |
Number |
0 |
|
| disabled |
Whether to disable slider |
Boolean |
false |
|
| max |
Max value |
Number |
100 |
|
| min |
Min value |
Number |
0 |
|
| step |
Step size |
Number |
1 |
|
| bar-height |
Height of bar |
String |
2px |
|
| active-color |
Active color of bar |
String |
#1989fa |
|
| inactive-color |
Inactive color of bar |
String |
#e5e5e5 |
|
| vertical |
Whether to display vertical |
Boolean |
false |
|
Event
| Event |
Description |
Arguments |
| change |
Triggered after value change |
value: current rate |
Slot
| Name |
Description |
| button |
Custom button |