微信小程序 调试库3.5.0 使用canvas调用drawImage方法无法画图 ? 求解答 无报错
const ctx = uni.createCanvasContext(canvaId, this); const fsm = wx.getFileSystemManager(); let extName = base64.match(/data\:\S+\/(\S+);/); if (extName) { extName = extName[1]; } // const ctx = uni.createCanvasContext(canvaId, this); let fileName = Date.now() + "." + extName; let filePath = wx.env.USER_DATA_PATH + "/" + fileName; fsm.writeFile({ filePath, data: base64.replace(/^data:\S+\/\S+;base64,/, ""), encoding: "base64", success: (res) => { wx.getImageInfo({ src: filePath, success: (res) => { console.log("Image info:", res, res.path); ctx.drawImage(res.path, 0, 0, 300, 300); // 使用获取到的图片路径 ctx.draw(false, () => { console.log("Canvas drawn"); }); // 绘制到画布 }, fail: (error) => { console.error("获取图片信息失败:", error); }, }); }, fail: (error) => { console.error("写入失败", error); }, });