美文网首页
js 将网页保存为图片并进行下载

js 将网页保存为图片并进行下载

作者: Dianaou | 来源:发表于2018-10-31 16:39 被阅读0次

之前以为不能实现这种效果,当出现了这个需求,就必须要实现一版,然后so easy,以下实现的代码:

html2canvas(document.querySelector("#capture")).then(canvas => {

var imgUri = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream"); // 获取生成的图片的url

        window.location.href= imgUri;

    // document.body.appendChild(canvas)

});

更多功能参考: https://github.com/linwalker/render-html-to-pdf

相关文章

网友评论

      本文标题:js 将网页保存为图片并进行下载

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