代码: <view style='width:0px;height:0px;overflow:hidden;'> <canvas class="myCanvas" canvas-id="mycanvas" type="2d"/> </view> //绘制画布 draImg(){ var logo = this.data.list[this.data.current]; if(!logo){ return; } ctx.drawImage(logo, 0, 0, 750, 1000); ctx.drawImage(this.data.qrcode, 580, 830, 129, 129) ctx.draw() ctx.setFontSize(34) ctx.fillText(this.data.nickname, 35, 857) ctx.draw(true) this.okgenerate(); }, //生成分享图 okgenerate() { //生成图片方法 var that = this setTimeout(() => { wx.canvasToTempFilePath({ //生成图片 quality: 1, canvasId: 'mycanvas', success: function (res) { wx.saveImageToPhotosAlbum({ //保存生成的图片到手机相册里 filePath: res.tempFilePath, success(res) { wx.showToast({ title: '保存成功', icon: 'success', duration: 2000 }) } }) }, fail: function (res) { console.log(res) } },that) }, 500) },
canvasToTempFilePath: fail canvas is empty?PC端能正常生成图片,手机端调试就报错??
2020-06-05