加载的html2canvas为官网上的新版本。
style样式:
*{
margin: 0;padding: 0;
font-family: "微软雅黑";
}
html,body{
width: 100%;
}
#capture,#imgDiv{
width: 100%;
}
.imgDiv_img{
width: 100%;
}
html:
页面内容
生成的图片
script代码:
$(function() {
html2canvas(document.querySelector("#capture")).then(function(canvas) {
var imgUri = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream"); // 获取生成的图片的url
$(".imgDiv_img").attr("src",imgUri)
})
});
原文:https://www.cnblogs.com/Andrea-Li/p/9914489.html