7
html to image 把html转换为图片
source link: https://blog.p2hp.com/archives/11706
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
html to image 把html转换为图片
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>
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK