前端合成图下载
downLoadPic(){
const self = this;
html2canvas(document.getElementById(‘xzPic’),{useCORS:true}).then(canvas=>{
var imgUri = canvas.toDataURL(“image/png”).replace(“image/png”, “image/octet-stream”); // 获取生成的图片的url
var dlLink = document.createElement(‘a’);
var fileName=self.yjxxTitle;
dlLink.download = fileName + ‘.png’;
dlLink.href = imgUri;
dlLink.dataset.downloadurl = [ “image/png”, dlLink.download, dlLink.href ].join(’:’);
document.body.appendChild(dlLink);
dlLink.click();
document.body.removeChild(dlLink);
});
}