在當前小程序版本中對於Canvas空間繪製圖片,存在bug,效率比較低。javascript
致使圖片回執完成慢。出現黑屏。java
解決方案:canvas
在調用draw(),繪製成功後,延遲使用繪製結果。例如:500毫秒後,輸出圖片內容。小程序
ctx.draw(false, function () { console.info('繪製成功'); setTimeout(function () { wx.canvasToTempFilePath({ canvasId: 'canvas1', fileType: 'jpg', quality: 1, success: res => { console.info(res); _this.setData({ imgPath: res.tempFilePath }); }, fail: res => { console.error(res); } }, this); },3000); });
更多:微信小程序