import html2canvas from 'html2canvas'
html2canvas(canvasDom, options).then(canvas => {
//此时的图片是base64格式的,我们将图片格式转换一下
let type = 'png';
let imgData = canvas.toDataURL(type);
// 照片格式处理
let _fixType = function(type) {
type = type.toLowerCase().replace(/jpg/i, 'jpeg');
let r = type.match(/png|jpeg|bmp|gif/)[0];
return 'image/' + r;
};
imgData = imgData.replace(_fixType(type), 'image/octet-stream');
let filename = this.row.name + '的二维码分享.' + type;
this.saveFile(imgData, filename);
})
saveFile(data, filename) {
let save_link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a');
save_link.href = data;
save_link.download = filename;
let event = document.createEvent('MouseEvents');
event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
save_link.dispatchEvent(event);
},