diff --git a/packages/slider/index.ts b/packages/slider/index.ts
index c6d03dfc..e06acdda 100644
--- a/packages/slider/index.ts
+++ b/packages/slider/index.ts
@@ -1,7 +1,7 @@
import { VantComponent } from '../common/component';
import { touch } from '../mixins/touch';
import { Weapp } from 'definitions/weapp';
-import { addUnit } from '../common/utils';
+import { canIUseModel } from '../common/version';
VantComponent({
mixins: [touch],
@@ -26,9 +26,7 @@ VantComponent({
value: {
type: Number,
value: 0,
- observer(value: number) {
- this.updateValue(value, false);
- },
+ observer: 'updateValue',
},
barHeight: {
type: null,
@@ -93,14 +91,13 @@ VantComponent({
updateValue(value: number, end: boolean, drag: boolean) {
value = this.format(value);
- const { barHeight, min } = this.data;
+ const { min } = this.data;
const width = `${((value - min) * 100) / this.getRange()}%`;
this.setData({
value,
barStyle: `
width: ${width};
- height: ${addUnit(barHeight)};
${drag ? 'transition: none;' : ''}
`,
});
@@ -112,6 +109,10 @@ VantComponent({
if (end) {
this.$emit('change', value);
}
+
+ if ((drag || end) && canIUseModel()) {
+ this.setData({ value });
+ }
},
getRange() {
diff --git a/packages/slider/index.wxml b/packages/slider/index.wxml
index d30d078b..6a430f38 100644
--- a/packages/slider/index.wxml
+++ b/packages/slider/index.wxml
@@ -1,4 +1,5 @@
+