canvas type=2d 获取的ctx 无法drawImage 地址为临时地址的图片
发布于 6 年前 作者 udong 4688 次浏览 来自 问答
2 回复
啥意思,canvasToTempFilePath后再把这张图拿去绘制?????
n难道不是通过downLoadFile获取本地图片后再绘制到canvas里吗?
 let canvasId=`canvas-qr`
    
    return new Promise((resolve, reject) => {
      Taro.canvasToTempFilePath({
        canvasId:canvasId,
        success(res3) {
          let tempFilePath = res3.tempFilePath;
           ctx.drawImage(tempFilePath,0,0,100,100);
          
        },
      });
    });

# 错误信息

VM3012 WAService.js:2 Unhandled promise rejection TypeError: Failed to execute ‘drawImage’ on ‘CanvasRenderingContext2D’: The provided value is not of type ‘(CSSImageValue or HTMLImageElement or SVGImageElement or HTMLVideoElement or HTMLCanvasElement or ImageBitmap or OffscreenCanvas)’

    at CanvasRenderingContext2D.Nd.e.drawImage (VM3012 WAService.js:2)

    at Index._callee2$ (createImg.js?t=wechat&s=1632809999604&v=5bac26123f77e3efc63b8794d8360e6c:176)

    at m (vendors.js?t=wechat&s=1632809999604&v=6439fe6ae0559aecf05f9424f15122c6:1)

    at Generator.t._invoke (vendors.js?t=wechat&s=1632809999604&v=6439fe6ae0559aecf05f9424f15122c6:1)

    at Generator.e.<computed> [as next] (vendors.js?t=wechat&s=1632809999604&v=6439fe6ae0559aecf05f9424f15122c6:1)

    at step (createImg.js?t=wechat&s=1632809999604&v=5bac26123f77e3efc63b8794d8360e6c:26)

    at createImg.js?t=wechat&s=1632809999604&v=5bac26123f77e3efc63b8794d8360e6c:26

    at VM3012 WAService.js:2

    at n (VM3012 WAService.js:2)(env: macOS,mp,1.05.2105170; lib: 2.19.6)

回到顶部