mirror of
https://github.com/youzan/vant.git
synced 2025-10-18 09:24:25 +00:00
Slider
Install
import Vue from 'vue';
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="-50" :max="50" />
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
Props
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 | `number | 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 |
Events
Event | Description | Arguments |
---|---|---|
input | Instant triggered when value changed | value: current rate |
change | Triggered after value changed | value: current rate |
drag-start | Triggered when start drag | - |
drag-end | Triggered when end drag | - |
Slots
Name | Description |
---|---|
button | Custom button |