html2canvas(document.body, {
useCORS: true,
allowTaint: true,
backgroundColor: '#ffffff',
// windowWidth: document.body.scrollWidth,
// windowHeight: document.body.scrollHeight,
height: document.body.offsetHeight,
width: document.body.offsetWidth,
// scrollTop,
dpi: window.devicePixelRatio * 2,
scale: 2,
scrollX: -window.scrollX,
scrollY: -window.scrollY
}).then(function (canvas) {
// toImage
const dataImg = new Image()
dataImg.src = canvas.toDataURL('image/png')
const alink = document.createElement("a");
alink.href = dataImg.src;
alink.download = "testImg.jpg";
alink.click();
});
html2canvas
最新推荐文章于 2024-07-18 15:24:52 发布