fix: 🐛 修复 wd-slider 滑块不跟手的问题 (#1114)

This commit is contained in:
量子蔷薇 2025-06-22 18:10:13 +08:00 committed by GitHub
parent 50782a1671
commit e3dc36e832
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,10 +1,10 @@
<template> <template>
<view :class="rootClass" :style="customStyle" :id="sliderId"> <view :class="rootClass" :style="customStyle">
<!-- #ifdef MP-DINGTALK --> <!-- #ifdef MP-DINGTALK -->
<view :id="sliderId" style="flex: 1" :class="rootClass"> <view style="flex: 1" :class="rootClass">
<!-- #endif --> <!-- #endif -->
<view :class="`wd-slider__label-min ${customMinClass}`" v-if="!hideMinMax">{{ minProp }}</view> <view :class="`wd-slider__label-min ${customMinClass}`" v-if="!hideMinMax">{{ minProp }}</view>
<view class="wd-slider__bar-wrapper" :style="wrapperStyle"> <view class="wd-slider__bar-wrapper" :style="wrapperStyle" :id="sliderBarWrapperId">
<view class="wd-slider__bar" :style="barStyle"> <view class="wd-slider__bar" :style="barStyle">
<template v-if="isRange"> <template v-if="isRange">
<!-- 左边滑块 --> <!-- 左边滑块 -->
@ -76,7 +76,7 @@ const props = defineProps(sliderProps)
const emit = defineEmits<SliderEmits>() const emit = defineEmits<SliderEmits>()
// ----------- ----------- // ----------- -----------
const sliderId = ref<string>(`sliderId${uuid()}`) const sliderBarWrapperId = ref<string>(`sliderBarWrapperId${uuid()}`)
const touch = useTouch() const touch = useTouch()
const touchIndex = ref<number>(0) const touchIndex = ref<number>(0)
const { proxy } = getCurrentInstance() as any const { proxy } = getCurrentInstance() as any
@ -232,7 +232,7 @@ function clamp(value: number, min: number, max: number): number {
* 初始化滑块宽度 * 初始化滑块宽度
*/ */
function initSlider() { function initSlider() {
getRect(`#${sliderId.value}`, false, proxy).then((data) => { getRect(`#${sliderBarWrapperId.value}`, false, proxy).then((data) => {
trackWidth.value = Number(data.width) trackWidth.value = Number(data.width)
trackLeft.value = Number(data.left) trackLeft.value = Number(data.left)
}) })