转换后我想要同样的图像。我试过canvas.toDataURL(" image / png");但这对我不起作用。我尝试了下面的代码,虽然它创建了一个img,但它没有显示截图。我是一个使用javascript的新手。你能帮忙吗?
function showImage()
{
html2canvas($('#hpImplement'),
{
onrendered: function(canvas)
{
var elem = document.createElement("img");
elem.setAttribute("src", canvas);
elem.setAttribute("alt", "Flower");
document.getElementById("hpShare").appendChild(elem);
},
});
}
我甚至尝试过:
function showImage()
{
html2canvas($('#hpImplement'),
{
onrendered: function(canvas)
{
var theCanvas = canvas.toDataURL("image/png");
var elem = document.createElement("img");
elem.setAttribute("src", theCanvas);
elem.setAttribute("alt", "Flower");
document.getElementById("hpShare").appendChild(elem);
},
});
}