...
ctx.draw(false, this.canvasToSrc())
...
canvasToSrc: async function() {
console.log('海报绘制完成')
const wxCanvasToTempFilePath = promisify(wx.canvasToTempFilePath)
const posterSrc = (await wxCanvasToTempFilePath({
canvasId: 'shareCanvas'
}, this)).tempFilePath
console.log(posterSrc)
wx.hideLoading()
this.setData({
posterSrc: posterSrc,
posterShow: true
})
},
首次执行,图片为空白,第二次执行才正常。我的理解是draw方法的回调有bug?
使用新的接口试下?https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html