<canvas
type="2d"
class="canvas"
catch:touchstart="catchtouchstart"
catch:touchmove="catchtouchmove"
></canvas>
onReady() {
this.initCanvas()
},
initCanvas() {
const {
windowWidth,
windowHeight,
pixelRatio: dpr
} = wx.getSystemInfoSync()
// 创建 canvas 画布上下文
wx.createSelectorQuery()
.select('.canvas')
.node()
.exec(res => {
const canvas = res[0].node
// 设置画布大小
canvas.width = windowWidth * dpr
canvas.height = windowHeight * dpr
this.data.canvas = canvas
// 初始化画布
this.data.ctx = canvas.getContext('2d')
this.data.ctx.textAlign = 'center'
this.data.ctx.font = '240px sans-serif'
this.data.ctx.fillStyle = '#E8EAED'
this.data.ctx.fillText('签名区', canvas.width / 2, 360)
this.data.ctx.scale(dpr, dpr)
})
},
catchtouchstart(e) {
// 判断开始签名
if (this.data.drawCount === 0) {
this.handleClear('emit')
}
const { clientX, clientY } = e.changedTouches[0]
this.data.drawCount++
this.data.ctx.strokeStyle = '#000000'
this.data.ctx.lineWidth = 6
this.data.ctx.lineCap = 'round'
this.data.ctx.lineJoin = 'round'
this.data.ctx.beginPath()
this.data.ctx.moveTo(clientX, clientY)
},
catchtouchmove(e) {
// 签名结束则不执行
if (this.data.drawState === 'stop') return
// 判断有多点触屏,则不执行
if (e.touches.length > 1) return
const { clientX, clientY } = e.changedTouches[0]
this.data.drawState = 'ing'
this.data.ctx.lineTo(clientX, clientY)
this.data.ctx.stroke()
this.data.ctx.moveTo(clientX, clientY)
},
会出现这种笔画跟触摸不同频的问题,手指在左边画,笔画出现在右边,而且还会延迟出现,其他机型正常,就15这个不行

这边测试16正常,换机型试试能不能复现