[fix] 修复slider滑块 从v-show隐藏到显示后,出现计算定位错误到问题

This commit is contained in:
zhengliming
2024-02-26 21:26:31 +08:00
parent 00c4852afb
commit 0d8ff2e98d

View File

@@ -149,6 +149,9 @@
},
// 滑动移动中
touchMove(event) {
this._tGetRect('.tn-slider').then(res => {
this.sliderRect = res
});
if (this.disabled) return
if (!event.changedTouches[0]) return
@@ -202,6 +205,9 @@
},
// 点击事件
click(event) {
this._tGetRect('.tn-slider').then(res => {
this.sliderRect = res
})
if (this.disabled) return
// 直接点击的情况计算方式和touchMove方法一致
const value = (((event.detail.x - this.sliderRect.left) / this.sliderRect.width) * (this.max - this.min)) + this.min