html to image 把html转换为图片
<div class="login-box" id="loginbox" style="width: 500px;">
要显示的内容
</div>
<script src="https://html2canvas.hertzen.com/dist/html2canvas.js"></script>
<script>
$(document).ready(function () {
setTimeout(function(){
downloadImage();
},1000)
});
functiondownloadImage(){
html2canvas(document.querySelector("#loginbox")).then(canvas=> {
a = document.createElement('a');
document.body.appendChild(a);
a.download = "test.png";
a.href = canvas.toDataURL();
a.click();
});
}
</script>

html to image 把html转换为图片
标签: