Why does canvas.toDataURL() throw a security exception?

后端 未结 10 1644
天涯浪人
天涯浪人 2020-11-22 12:56

Did I not get enough sleep or what? This following code

var frame=document.getElementById(\"viewer\");
frame.width=100;
frame.height=100;

var ctx=frame.getC         


        
10条回答
  •  耶瑟儿~
    2020-11-22 14:00

    I'm using fabric.js and could resolve this by using toDatalessJSON instead of toDataURL:

    canvas.toDatalessJSON({ format: 'jpeg' }).objects[0].src
    

    Edit: Nevermind. This results in just the background image being exported to JPG, without the drawing on top so it was not entirely useful after all.

提交回复
热议问题