将 html 转化为canvas 画布
类似于 截图
html2canvas.js
https://www.bootcdn.cn/ cdn中会有
var test = $(".test").get(0); //将jQuery对象转换为dom对象
// 点击转成canvas
$('.toCanvas').click(function(e) {
// 调用html2canvas插件
html2canvas(test).then(function(canvas) {
$('.toCanvas').after(canvas);
//将画布转换为base64
var base64 = canvas.toDataURL("image/png");
console.log(base64);
document.getElementById('nowPic').src=base64;
});
});
随后转称base64 方便对图片操作