[Improvement] Slider: add step & bar-height prop (#915)

This commit is contained in:
neverland
2018-04-23 20:19:41 +08:00
committed by GitHub
parent 19f4c9c028
commit b93a2e3c00
7 changed files with 160 additions and 350 deletions
+34 -77
View File
@@ -11,99 +11,56 @@ Vue.use(Slider);
#### Basic Usage
```html
<van-slider v-model="value1"/>
<van-row>
<van-col span="12">
<van-stepper v-model="value1" />
</van-col>
</van-row>
<van-slider v-model="value" @change="onChange" />
```
```js
data() {
return {
value1: 50
}
}
```
#### Max && Min
```html
<van-slider
v-model="value2"
:min="min"
:max="max"
/>
```
```js
data() {
return {
value2: 50,
min: 10,
max: 90
}
}
```
#### Disabed
```html
<van-slider v-model="value3" disabled />
```
#### Customized style
```html
<van-slider
v-model="value4"
@change="handleChange"
@after-change="handleAfterChange"
/>
```
```js
data() {
return {
value4: 50
}
},
methods: {
handleChange(value) {
console.log('handleChange:', value)
export default {
data() {
return {
value: 50
};
},
handleAfterChange(value) {
console.log('handleAfterChange:', value)
methods: {
onChange(value) {
this.$toast('Current value' + value);
}
}
}
};
```
### Customized style
#### Range
```html
<van-slider
v-model="value5"
pivot-color="#333"
loaded-bar-color="red"
bar-color="blue"
/>
<van-slider v-model="value" :min="10" :max="90" />
```
#### Disabled
```html
<van-slider v-model="value" disabled />
```
#### Step size
```html
<van-slider v-model="value" :step="10" bar-height="4px" />
```
### API
| Attribute | Description | Type | Default | Accepted Values |
| Attribute | Description | Type | Default |
|-----------|-----------|-----------|-------------|-------------|
| value | current value | Number | 0 | - |
| disabled | disabled | Boolean | false | - |
| bar-color | bar-color | string | `#cacaca` | - |
| loaded-bar-color | loaded-bar-color | string | `#4b0` | - |
| pivot-color | pivot-color | string | `#4b0` | - |
| max | max | Number | 100 | - |
| min | min | Number | 0 | - |
| 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` |
### Event
| Event | Description | Arguments |
|-----------|-----------|-----------|
| change | touchmove emit | value |
| after-change | touchend emit | value |
| change | Triggered after value change | value: current rate |