npm install html2canvas
import html2canvas from 'html2canvas';
創(chuàng)建節(jié)點(diǎn)筹误,調(diào)用html2canvas
<div id="capture" style="padding: 10px; background: #f5da55">
<h4 style="color: #000; ">Hello world!</h4>
</div>
<script>
html2canvas(document.querySelector("#capture")).then(canvas => {
let img = canvas.toDataURL()
location.href=img
});
</script>