diff --git a/src/components/slider/slider.vue b/src/components/slider/slider.vue
index d8e29e4..bb591c1 100644
--- a/src/components/slider/slider.vue
+++ b/src/components/slider/slider.vue
@@ -5,11 +5,11 @@
:min="min"
:max="max"
:step="step"
- :value="currentValue[0]"
+ :value="exportValue[0]"
:disabled="disabled"
@on-change="handleInputChange">
-
+
@@ -19,7 +19,7 @@
:style="{left: minPosition + '%'}"
@touchstart="onPointerDown($event, 'min')"
@mousedown="onPointerDown($event, 'min')">
-
@@ -29,7 +29,7 @@
:style="{left: maxPosition + '%'}"
@touchstart="onPointerDown($event, 'max')"
@mousedown="onPointerDown($event, 'max')">
-
@@ -120,16 +120,16 @@
this.currentValue = val;
}
},
- currentValue (val) {
+ exportValue (values) {
this.$nextTick(() => {
this.$refs.minTooltip.updatePopper();
if (this.range) {
this.$refs.maxTooltip.updatePopper();
}
});
- const exportValue = this.range ? val : val[0];
- this.$emit('input', exportValue);
- this.$emit('on-input', exportValue);
+ const value = this.range ? values : values[0];
+ this.$emit('input', value);
+ this.$emit('on-input', value);
}
},
computed: {
@@ -159,6 +159,10 @@
}
];
},
+ exportValue(){
+ const decimalCases = (String(this.step).split('.')[1] || '').length;
+ return this.currentValue.map(nr => Number(nr.toFixed(decimalCases)));
+ },
minPosition () {
const val = this.currentValue;
return (val[0] - this.min) / this.valueRange * 100;
@@ -269,9 +273,9 @@
},
emitChange(){
- const exportValue = this.range ? this.currentValue : this.currentValue[0];
- this.$emit('on-change', exportValue);
- this.dispatch('FormItem', 'on-form-change', exportValue);
+ const value = this.range ? this.exportValue : this.exportValue[0];
+ this.$emit('on-change', value);
+ this.dispatch('FormItem', 'on-form-change', value);
},
sliderClick (event) {
@@ -287,9 +291,7 @@
handleInputChange (val) {
this.currentValue = [val, this.currentValue[1]];
- const exportValue = this.range ? this.currentValue : this.currentValue[0];
- this.$emit('on-change', exportValue);
- this.dispatch('FormItem', 'on-form-change', exportValue);
+ this.emitChange();
},
},
mounted () {
--
libgit2 0.21.4