官方关于 wx.canvasToTempFilePath 的说明:
把当前画布指定区域的内容导出生成指定大小的图片。在 draw() 回调里调用该方法才能保证图片导出成功。
https://developers./miniprogram/dev/api/canvas/wx.canvasToTempFilePath.html
ctx.draw(false, ()=>{wx.showLoading({title: '图片保存中...',mask: true})wx.canvasToTempFilePath({canvasId: 'myCanvas',success: function (res) {wx.saveImageToPhotosAlbum({filePath: res.tempFilePath,success(result) {wx.showModal({title: '提示',content: '图片已保存到相册,文案已自动复制,发朋友圈时只需勾选图片并粘贴文案即可',showCancel: false,confirmText: '我知道了',success (res) {if (res.confirm) {}}})},complete(){wx.hideLoading();},})}})});