无法在image标签里显示的代码
ctx.drawImage("/" + resp.path, 175, imgH - 370, 250, 250);
ctx.draw();
wx.canvasToTempFilePath({
canvasId: "myCanvas",
success: res => {
console.log("合成的带有小程序码的图片success》》》", res);
let tempFilePath = res.tempFilePath;
this.resultImg = tempFilePath; // image标签获取图片路径
},
fail: e => {
console.log(e);
}
});
无法显示的原因:异步执行
解决办法
ctx.drawImage("/" + resp.path, 175, imgH - 370, 250, 250);
ctx.draw(false, () => {
wx.canvasToTempFilePath({
canvasId: "myCanvas",
success: res => {
console.log("合成的带有小程序码的图片success》》》", res);
let tempFilePath = res.tempFilePath;
this.resultImg = tempFilePath;
},
fail: e => {
console.log(e);
}
});
});