create screenshot of webpage using html2canvas (unable to initialize properly)

后端 未结 5 2189
醉酒成梦
醉酒成梦 2020-12-01 06:03

I am attempting to use http://html2canvas.hertzen.com/ to take screenshots of my webpage. I am unable to initialize a canvas element using...

var canvas = $         


        
5条回答
  •  心在旅途
    2020-12-01 06:33

    You should use it this way:

    $('body').html2canvas();
    var queue = html2canvas.Parse();
    var canvas = html2canvas.Renderer(queue,{elements:{length:1}});
    var img = canvas.toDataURL();
    window.open(img);
    

    It took me few hours to figure it out, how to use it the right way. The {elements:{length:1}} is required, due to incomplete implementation of the plugin, otherwise you'll get an error.

    Good luck!

提交回复
热议问题