canvas 在 bindtouchmove 方法中 绘制问题
发布于 7 年前 作者 vliu 6540 次浏览 来自 官方Issues

canvas 在 bindtouchmove 方法中 使用draw方法画线 出现问题

在开发者工具和苹果手机上都没有问题

安卓手机有问题,可以复现出来,左上角的点 有时候会连着画的那个点

正常情况:

有问题的情况:

<canvas canvas-id=“canvas” class=“canvas” bindtouchstart=“start” bindtouchmove=“move” bindtouchend=“end” disable-scroll></canvas>

sign() {

this.setData({

hidden: false

});

const ctx = wx.createCanvasContext(‘canvas’)

ctx.setLineWidth(3)

ctx.setLineJoin(‘round’)

ctx.setLineCap(‘round’)

ctx.draw()

this.setData({

ctx

})

},

start({

touches

}) {

// console.log(‘start’, touches[0].x, touches[0].y)

const ctx = this.data.ctx

ctx.moveTo(touches[0].x, touches[0].y)

},

move({

touches

}) {

// console.log(‘move’, touches[0].x, touches[0].y)

const ctx = this.data.ctx

ctx.lineTo(touches[0].x, touches[0].y)

ctx.stroke()

ctx.draw(true, () => {

ctx.moveTo(touches[0].x, touches[0].y)

})

},

2 回复

请问楼主解决了吗,我这也遇到同样的问题,郁闷~

moveTo之后加个 beginPath呢

回到顶部