:class="{'scroll-disabled': isYScroll}"
.scroll-disabled {
overflow: hidden;
}
// 触摸开始事件处理
const handleMouseDown = (e: TouchEvent) => {
startX.value = e.touches[0].clientX
startY.value = e.touches[0].clientY
isDragging.value = true
console.log('触摸开始', startX.value, startY.value)
}
// 触摸结束事件处理
const handleMouseUp = (e: TouchEvent) => {
isDragging.value = false
console.log('触摸结束')
isYScroll.value = false
}
// 触摸移动事件处理
const handleMouseMove = (e: TouchEvent) => {
if (!isDragging.value) return
const currentX = e.touches[0].clientX
const currentY = e.touches[0].clientY
const deltaX = currentX - startX.value
const deltaY = currentY - startY.value
// 如果水平移动距离小于垂直移动距离,
if (Math.abs(deltaX) < Math.abs(deltaY)) {
isYScroll.value = true
}
}