收藏
回答

canvas type=2d 获取的ctx 无法drawImage 地址为临时地址的图片

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug drawImage 微信iOS客户端 8.0.6 2.19.6

https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.drawImage.html

回答关注问题邀请回答
收藏

2 个回答

  • Code Weaver
    Code Weaver
    2021-09-29
    啥意思,canvasToTempFilePath后再把这张图拿去绘制?????
    n难道不是通过downLoadFile获取本地图片后再绘制到canvas里吗?
    


    2021-09-29
    有用
    回复 3
  • 比丢
    比丢
    2021-09-28
     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)

    2021-09-28
    有用
    回复
登录 后发表内容