html2canvas
1.安装
cnpm install --save html2canvas
2.引用
components: {
html2canvas
}
3.方法
html2canvas(document.getElementById("pdf_canvas_1")).then(function (canvas) {
console.log(canvas)
/*图片格式:image/jpg、image/png、image/jpeg等*/
var image = canvas.toDataURL("image/png");
let $a = document.createElement('a');
$a.setAttribute("href", image);
$a.setAttribute("download", "图片名称");
$a.click();
});
}