diff --git a/example/pages/slider/index.wxml b/example/pages/slider/index.wxml index e9a2392f..0a35ef8d 100644 --- a/example/pages/slider/index.wxml +++ b/example/pages/slider/index.wxml @@ -67,7 +67,7 @@ { const { vertical } = this.data; + const touch = event.touches[0]; const delta = vertical - ? event.detail.y - rect.top - : event.detail.x - rect.left; + ? touch.clientY - rect.top + : touch.clientX - rect.left; const total = vertical ? rect.height : rect.width; const value = Number(min) + (delta / total) * this.getRange(); @@ -160,7 +161,7 @@ VantComponent({ this.setData({ wrapperStyle: ` background: ${this.data.inactiveColor || ''}; - ${mainAxis}: ${addUnit(this.data.barHeight) || ''}; + ${vertical ? 'width' : 'height'}: ${addUnit(this.data.barHeight) || ''}; `, barStyle: ` ${mainAxis}: ${this.calcMainAxis()};