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
标签:canvas,导出,canvasToTempFilePath,报错,fail,uni,empty From: https://www.cnblogs.com/huzhuhua/p/17840483.html