ctx.draw(false, () => {
wx.showToast({
title:'正在生成海报',
icon:'loading'
})
wx.canvasToTempFilePath({
canvasId: 'ctx',
success(res) {
console.log(res.tempFilePath)
_this.setData({
posterUrl: res.tempFilePath
})
wx.hideToast();
},
fail(m) {
console.log(m);
}
})
});
安卓真机调试:

setTimeout一下
setTimeout(function() { wx.canvasToTempFilePath({...},2000);ctx.draw(false, () => {wx.showToast({title: '正在生成海报',icon: 'loading'})setTimeout(function() {wx.canvasToTempFilePath({canvasId: 'ctx',success(res) {console.log(res.tempFilePath)_this.setData({posterUrl: res.tempFilePath})wx.hideToast();},fail(m) {console.log(m);}})}, 0)});有大佬看看我的问题吗,canvastotempfilepath 有几率生成空图
使用新的接口试下呢?
https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html