feat(Slider): bar-height prop support number (#1971)

This commit is contained in:
Jake 2019-09-06 10:26:04 +08:00 committed by neverland
parent 50478da7ef
commit 17b13d5616
2 changed files with 5 additions and 3 deletions

View File

@ -91,7 +91,7 @@ Page({
| max | 最大值 | *number* | `100` | | max | 最大值 | *number* | `100` |
| min | 最小值 | *number* | `0` | | min | 最小值 | *number* | `0` |
| step | 步长 | *number* | `1` | | step | 步长 | *number* | `1` |
| bar-height | 进度条高度 | *string* | `2px` | | bar-height | 进度条高度,默认单位为 `px` | *string \| number* | `2px` |
| active-color | 进度条激活态颜色 | *string* | `#1989fa` | | active-color | 进度条激活态颜色 | *string* | `#1989fa` |
| inactive-color | 进度条默认颜色 | *string* | `#e5e5e5` | | inactive-color | 进度条默认颜色 | *string* | `#e5e5e5` |

View File

@ -1,6 +1,7 @@
import { VantComponent } from '../common/component'; import { VantComponent } from '../common/component';
import { touch } from '../mixins/touch'; import { touch } from '../mixins/touch';
import { Weapp } from 'definitions/weapp'; import { Weapp } from 'definitions/weapp';
import { addUnit } from '../common/utils';
VantComponent({ VantComponent({
mixins: [touch], mixins: [touch],
@ -27,7 +28,7 @@ VantComponent({
value: 0 value: 0
}, },
barHeight: { barHeight: {
type: String, type: null,
value: '2px' value: '2px'
} }
}, },
@ -77,10 +78,11 @@ VantComponent({
updateValue(value: number, end: boolean, drag: boolean) { updateValue(value: number, end: boolean, drag: boolean) {
value = this.format(value); value = this.format(value);
const { barHeight } = this.data;
this.set({ this.set({
value, value,
barStyle: `width: ${value}%; height: ${this.data.barHeight};` barStyle: `width: ${value}%; height: ${addUnit(barHeight)};`
}); });
if (drag) { if (drag) {