// view
<canvas type="2d" canvas-id="myCanvas" id="myCanvas" class="myCanvas"></canvas>
// js
wx.canvasToTempFilePath({ //将canvas生成图片
canvasId: 'myCanvas',
x: 0,
y: 0,
width: 300,
height: 450,
success: function (res) {
let {
tempFilePath
} = res.tempFilePath //图片临时路径
// let urls = '../../image/guide.jpg' //图片临时路径
wx.saveImageToPhotosAlbum({
filePath: tempFilePath, //canvasToTempFilePath返回的tempFilePath
success: (res) => {
console.log(tempFilePath)
},
fail: (err) => {}
})
}
}, this)
}
// 报错
call failed:, {errMsg: "canvasToTempFilePath:fail fail canvas is empty"}
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。