美文网首页
实用第三方工具——html2canvas页面转canvas生成图

实用第三方工具——html2canvas页面转canvas生成图

作者: MagicianKevin | 来源:发表于2020-07-14 13:36 被阅读0次

    引入html2canvas

    npm install html2canvas

    import html2canvas from 'html2canvas';
    

    创建节点,调用html2canvas

    <div id="capture" style="padding: 10px; background: #f5da55">
        <h4 style="color: #000; ">Hello world!</h4>
    </div>
    <script>
    html2canvas(document.querySelector("#capture")).then(canvas => {
      let img = canvas.toDataURL()
      location.href=img
    });
    </script>
    

    相关文章

      网友评论

          本文标题:实用第三方工具——html2canvas页面转canvas生成图

          本文链接:https://www.haomeiwen.com/subject/tgwxhktx.html