async drawImage() { let self = this; //这里是重点 新版本的type 2d 获取方法 const query = wx.createSelectorQuery(); const canvasObj = await new Promise((resolve, reject) => { query .select("#" + this.id) .fields({ node: true, size: true }) .exec(async (res) => { resolve(res[0].node); }); }); console.log(canvasObj); wx.canvasToTempFilePath( { //fileType: 'jpg', //canvasId: 'posterCanvas', //之前的写法 canvas: canvasObj, //现在的写法 Object类型 success: (res) => { console.log(res, '图片=========》'); // self.setData({ canClose: true }); //保存图片 }, fail(res) { console.log(res); }, }, this ); },
wx.canvasToTempFilePath报错?"canvasToTempFilePath:fail Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The provided value is not of type '(CSSImageValue or HTMLImageElement or SVGImageElement or HTMLVideoElement or HTMLCanvasElement or ImageBitmap or OffscreenCanvas or VideoFrame)'" 提供的值不是类型”(CSSImageValue或HTMLImageElement或SVGImageElement或HTMLVideoElement或HTMLCanvasElement或ImageBitmap或OffsetCanvas或VideoFrame)
2023-04-18