在开发工具上是https://协议开头,一旦切换到真机调试就成wxfile://协议
//导出成图片
btnImg: function () {
wx.canvasToTempFilePath({
destWidth: 500,
destHeight: 500,
canvasId: ‘canvasId’,
success: function (res) {
console.log(‘res.tempFilePath:’+res.tempFilePath);
wx.downloadFile({
url: res.tempFilePath,
success: function (res) {
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: function (data) {
wx.showModal({
title: ‘下载成功’,
content: ‘图片以保存至您的手机’,
})
},
fail: function () {
console.log(‘error’);
}
})
}
})
}
})
},
真机调试截图
开发者工具截图