微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

html2canvas

编程之家收集整理的这个编程导航主要介绍了html2canvas编程之家,现在分享给大家,也给大家做个参考。

html2canvas 介绍

html2canvas可以通过纯js对浏览器端经行截屏,但截图的精确度还有待提高,部分css不可识别,所以在canvas中不能完美呈现原画面样式 。

 html2canvas兼容性:

Firefox 3.5+ 

Google Chrome 

Opera 12+ 

IE9+ 

Safari 6+ 

html2canvas使用

1、安装npm install --save html2canvas//或者yarn add html2canvas2、使用html2canvas 的使用非常简单,简单到只需要传入一个 DOM 元素,然后通过回调拿到 canvas  html:<div id="capture" padding: 10px; background: #f5da55"><h4 color: #000; ">Hello World!</h4></div>js:html2canvas(document.querySelector("#capture")).then(canvas => {document.body.appendChild(canvas)});

html2canvas注意点  

1.html2canvas 通过解析元素实际的样式来生成 canvas 图片内容,因此它对元素实际的布局和视觉显示有要求。如果要完整截图,最好将元素从文档流中独立出来(例如 position:absolute)

2.生成的 canvas 图片在 retina 设备上显示很模糊,处理成 2 倍图能解决这个问题

网站地址:https://html2canvas.hertzen.com/

GitHub:https://github.com/niklasvh/html2canvas

网站描述:一个js实现从浏览器网页截图的开源库

html2canvas

官方网站:https://html2canvas.hertzen.com/

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。