Skip to content

Commit

Permalink
fix: slider组件change事件传参
Browse files Browse the repository at this point in the history
  • Loading branch information
jry committed Dec 18, 2024
1 parent 92ccacc commit fe2e8a2
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/uni_modules/uview-plus/components/u-slider/u-slider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@
this.newValue = ((this.distanceX / this.sliderRect.width) * (this.max - this.min)) + parseFloat(this.min);
this.status = 'moving';
// 发出moving事件
this.$emit('changing');
this.updateValue(this.newValue, true, index);
$crtFmtValue = this.updateValue(this.newValue, true, index);
this.$emit('changing', $crtFmtValue);
},
onTouchMove(event, index = 1) {
if (this.disabled) return;
Expand All @@ -293,14 +293,14 @@
this.newValue = ((this.distanceX / this.sliderRect.width) * (this.max - this.min)) + parseFloat(this.min);
this.status = 'moving';
// 发出moving事件
this.$emit('changing');
this.updateValue(this.newValue, true, index);
$crtFmtValue = this.updateValue(this.newValue, true, index);
this.$emit('changing', $crtFmtValue);
},
onTouchEnd(event, index = 1) {
if (this.disabled) return;
if (this.status === 'moving') {
this.updateValue(this.newValue, false, index);
this.$emit('change');
$crtFmtValue = this.updateValue(this.newValue, false, index);
this.$emit('change', $crtFmtValue);
}
this.status = 'end';
},
Expand Down Expand Up @@ -373,7 +373,11 @@
default:
break;
}
if (this.isRange) {
return this.rangeValue
} else {
return valueFormat
}
},
format(value, index = 1) {
// 将小数变成整数,为了减少对视图的更新,造成视图层与逻辑层的阻塞
Expand Down

0 comments on commit fe2e8a2

Please sign in to comment.