通过html2canvas生成一张图片,发现checkbox选中项并没有截图成功。
html2canvas
我是div
性别:
男
女
function createImage(){
html2canvas(document.getElementById('myPage'),{
allowTaint:true,
height: 500
}).then(function(canvas) {
console.log(canvas);
var aTag = document.createElement("a");
aTag.innerHTML = "This is a test";
aTag.setAttribute("style", "position:absolute; top:50%; z-index:999");
aTag.setAttribute("href", canvas.toDataURL());
aTag.setAttribute("download", "myPic.png");
document.body.appendChild(aTag);
});
}
页面以及生产图片: