操作:在浏览器F12中console执行代码
1.var script = document.createElement('script');
script.src = "http://html2canvas.hertzen.com/dist/html2canvas.min.js";
document.getElementsByTagName('head')[0].appendChild(script);
2.html2canvas(document.querySelector("body")).then(canvas => {
document.body.appendChild(canvas)
});
如图:
html代码执行js脚本可生成图片