wx.canvasToTempFilePath() 真机导出失败,模拟器正常。
fail invalid viewId
终端类型:微信iOS客户端
微信版本:8.0.40
代码片段如下:
let wxaCode = 'data:image/png;base64,xxx...';
let canvas = wx.createOffscreenCanvas({type: '2d', width: 500, height: 500});
let ctx = canvas.getContext('2d');
let image = canvas.createImage();
image.onload = function () {
ctx.fillStyle = '#ffffff';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
wx.canvasToTempFilePath({
canvas: canvas,
fileType: 'jpg',
success: console.log,
fail: console.error
})
}
image.src = wxaCode;
暂时已解决,使用文件系统写入文件
参考链接:
canvas 2d 报错 toTempFilePath:fail invalid viewid?? 瓦力|🇨🇳 的回答 - 微信开放社区 https://developers.weixin.qq.com/community/develop/doc/00002c853e0f3050569b2c90a51000?jumpto=comment&commentid=0002409c044320491e3e016eb5b0