wx.canvasToTempFilePath 方法根本运行不了 只打印出开始了跟走过了 有没有大佬解答下
createQrCode: function (url, canvasId, cavW, cavH) {
//调用插件中的draw方法,绘制二维码图片
QR.api.draw(url, canvasId, cavW, cavH);
setTimeout(() => { this.canvasToTempImage(); }, 2000);
},
canvasToTempImage: function () {
console.log('开始了');
wx.canvasToTempFilePath({
canvasId: 'mycanvas',
success: function (res) {
console.log(res);
var tempFilePath = res.tempFilePath;
console.log(tempFilePath);
this.setData({
imagePath: tempFilePath,
});
},
fail: function (res) {
console.log('错误');
console.log(res);
}
});
console.log('走过了');
},
遇见了和你完全一样的问题,一开始还导出过两次,后来怎么都不行了,这个方法也不报任何错误!
https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.draw.html
https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.canvasToTempFilePath.html