try catch 无法捕获到错误,没有回调,没有反应,宛如石化一般,孤寂无边。
原本写法:
ctx.draw(false, () => { let a = setTimeout(async () => { const [err, res] = await uni.canvasToTempFilePath({ canvasId: "canvas", }); this.poster_img = res.tempFilePath; clearTimeout(a); }, 250); });
把回调写成立即执行:
ctx.draw(true, (() => { let a = setTimeout(async () => { const [err, res] = await uni.canvasToTempFilePath({ canvasId: "canvas", }); this.poster_img = res.tempFilePath; clearTimeout(a); }, 250); })());