weixin_39707597
2020-11-22 16:29 阅读 3

drawImage failed execution

I'm receiving this error when I try to use mode 3/4 (images).

Uncaught TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': No function was found that matched the signature provided.

Any ideas as to why this would be happening?

该提问来源于开源项目:lrsjng/jquery-qrcode

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

6条回答 默认 最新

  • weixin_39630813 weixin_39630813 2020-11-22 16:29

    you have to pass in an <image> element to the image option

    点赞 评论 复制链接分享
  • weixin_39707597 weixin_39707597 2020-11-22 16:29

    Like this? Still errors for me. Sorry to bother you but thank you for your time.

    
    $("#qrCode").qrcode({
                "render":"canvas",
                "width": 100,
                "height": 100,
                "color": "#3a3",
                "text": "= $url ?>",
                "mode": 3,
                "image": "<img src="https://img-blog.csdnimg.cn/img_convert/37cd2ec796e5a159bf4b8f872b5d2215.png">"
            });
    
    点赞 评论 复制链接分享
  • weixin_39630813 weixin_39630813 2020-11-22 16:29

    for example include the image to your page with (can be hidden/invisible):

    
    <img id="my-image" src="https://img-blog.csdnimg.cn/img_convert/37cd2ec796e5a159bf4b8f872b5d2215.png">
    

    and then use it like this:

    
    image: $('#my-image')[0]
    
    点赞 评论 复制链接分享
  • weixin_39630813 weixin_39630813 2020-11-22 16:29

    does it work now?

    点赞 评论 复制链接分享
  • weixin_39707597 weixin_39707597 2020-11-22 16:29

    Yes, it does. Thanks for your time! I'll be buying you a beer.

    点赞 评论 复制链接分享
  • weixin_39630813 weixin_39630813 2020-11-22 16:29

    thank you! :)

    点赞 评论 复制链接分享

相关推荐