canvas 在 bindtouchmove 方法中 绘制问题
发布于 6 年前 作者 sxu 11822 次浏览 来自 官方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)

})

},

1 回复

麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

回到顶部