let doc = document.getElementById("shareInfo");
html2canvas(doc, {
useCORS: true,
height: doc.clientHeight - 2, // 根据具体情况进行调整
width: doc.clientWidth - 2,
}).then((canvas) => {
const newSrc = canvas.toDataURL("image/png");
console.log(newSrc);
tempImg.value = newSrc;
});
具体介绍可以看官网:html2canvas - Screenshots with JavaScripthttps://html2canvas.hertzen.com/