示例代码
<!-- 手写板区域 -->
<view class="sign-content">
<!-- 手写板 -->
<canvas
canvas-id="sign"
class="sign"
:disable-scroll="true"
@touchstart="onTouchStart"
@touchmove="onTouchMove"
@touchend="onTouchEnd"
@touchcancel="onTouchEnd"
/>
</view>
/**
* 手指按下事件
* @param {TouchEvent & WechatMiniprogram.TouchCanvas} event 触摸事件
*/
function onTouchStart(event: TouchEvent & WechatMiniprogram.TouchCanvas): void {
console.log(JSON.stringify(event))
}
/**
* 手指移动事件
* @param {TouchEvent & WechatMiniprogram.TouchCanvas} event 触摸事件
*/
function onTouchMove(event: TouchEvent & WechatMiniprogram.TouchCanvas): void {
console.log(JSON.stringify(event))
}
/**
* 手指抬起事件
* @param {TouchEvent & WechatMiniprogram.TouchCanvas} event 触摸事件
*/
function onTouchEnd(event: TouchEvent & WechatMiniprogram.TouchCanvas): void {
console.log(JSON.stringify(event))
}