不多说,上代码
function test() {
html2canvas($('#test'),{
dpi:1000,
onrendered: function(canvas) {
convertCanvasToImage(canvas);
}
})
}
function convertCanvasToImage(canvas) {
var image = new Image();
image.src = canvas.toDataURL("image/png");
image.style.width = canvas.width/11 + 'px';
image.style.height = canvas.height/11 + 'px';
$('#jme-math').empty();
$('#jme-math').append(image)
return image;
}
其中,可以根据实际需要修改这里,调整图片大小
image.style.width = canvas.width/11 + 'px';
image.style.height = canvas.height/11 + 'px';