首页 > 编程语言 >微信小程序使用canvas导出图片时提示报错为canvasToTempFilePath:fail fail canvas is empty

微信小程序使用canvas导出图片时提示报错为canvasToTempFilePath:fail fail canvas is empty

时间:2023-11-18 15:03:17浏览次数:53  
标签:canvas 导出 canvasToTempFilePath 报错 fail uni 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

 

标签:canvas,导出,canvasToTempFilePath,报错,fail,uni,empty
From: https://www.cnblogs.com/huzhuhua/p/17840483.html

相关文章