<canvas class="handWriting" disable-scroll="true" bindtouchstart="canvasTouchStart" bindtouchmove="canvasTouchMove" id="handSigin" canvas-id="handWriting1"/> startCanvar(){ var that = this const query = wx.createSelectorQuery() query.select('#handSigin').fields({node:true,size:true,context:true}).exec(function (res){ console.log('canvas====>',res) const canvas = res[0] const ctx = canvas.context // ctx.fillStyle = 'red' // ctx.fillRect(0, 0, 100, 100) that.setData({ context1: ctx, }) }) }, canvasTouchStart(e) { console.log('touchstart1==1111==>>',e) if(!this.data.isSingDialog){ this.setData({ dialogShow:true, showCanbans:false }) return } var context1 = this.data.context1; context1.moveTo(e.touches[0].x, e.touches[0].y); this.setData({ context1: context1, hasDraw : true, //要签字了 }); }, canvasTouchMove: function(e) { console.log('touchmove1===11111==>>',e) if(!this.data.isSingDialog){ return } var x = e.touches[0].x; var y = e.touches[0].y; var context1 = this.data.context1; context1.setLineWidth(3); context1.lineTo(x, y); context1.stroke(); context1.setLineCap('round'); context1.draw(true); context1.moveTo(x, y); },
小程序Canvas在PC端打开bindtouchstart,bindtouchmove无法触发?api组件名称:canvas,最低基础库:2.20.2,pc微信版本号:3.9.0.28 问题描述:使用canvas开发签字板功能,初次打开pc端小程序可使用,使用几次过或一段时间之后,再次使用,canvas的相关事件均无法触发导致无法使用
2023-02-08