2***@qq.com
2***@qq.com
  • 发布:2025-07-21 18:01
  • 更新:2025-07-21 18:01
  • 阅读:37

canvas组件的@touchstart、@touchmove、@touchend获取的坐标是从屏幕左上角开始?

分类:uni-app x

canvas组件的@touchstart、@touchmove、@touchend获取的坐标是从屏幕左上角作为原点开始?
为什么不是从画布的左上角作为原点?

<canvas id="canvas" ref="canvas" style="width: 600rpx;height: 360rpx;"  
                            @touchstart="handleTouchStart" @touchmove="handleTouchMove"  
                            @touchend="handleTouchEnd"></canvas>  

handleTouchStart(e : TouchEvent) {  
                if (this.ctx != null) {  
                    const touch = e.touches[0];  
                    let x = touch.clientX  
                    let y = touch.clientY  
                    console.log(x, y)  
                }  
            },  

//other like this
2025-07-21 18:01 负责人:无 分享
已邀请:

要回复问题请先登录注册