微信小程序使用canvas导出图片时提示报错为canvasToTempFilePath:fail fail canvas is empty
uni使用小程序 时,组件里面有个canvas,页面上面也有一个canvs。组件里面的canvas想导出图片,报canvasToTempFilePath:fail fail canvas is empty。
在canvasToTempFilePath里面要加上第二个参数,传入this;
uni.canvasToTempFilePath({ canvasId: "canvas", x: 0, y: 0, destHeight: this.imgH, destWidth: this.imgW, width: this.imgW, height: this.imgH, success: (res) => { }, fail: (e) => { } }, this)
let ctx = uni.createCanvasContext("canvas", this);//生成画笔的时候也是 要传入this