把div变成canvas图片 html2canvas

HTML部分:

js部分:

html2canvas($('#shareDetail'),{
    onrendered: function(canvas) {
        convertCanvasToImage(canvas);
    }
});
function convertCanvasToImage(canvas) {
    $('#shareDetail').remove();
    var imgStr = canvas.toDataURL("image/png");
    var img=new Image();
    img.src=imgStr;
    $('.shareDetail-box').append(img);
}

你可能感兴趣的:(把div变成canvas图片 html2canvas)