2023-09-22 uniapp canvas之ctx.draw没有回调 ==》ctx.draw(true, (() => {...})())

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);
})());
posted @ 2023-09-22 14:07  叶乘风  阅读(621)  评论(0编辑  收藏  举报