canvas转png下载
使用gojs时生成的canvas没有id,所以是通过tagName获取的
如果canvas有id,直接var canvasElement = document.getElementById(“canvasId”);
exportCanvasAsPNG(fileName) {
var canvasElement = document.getElementsByTagName("canvas");
console.log(canvasElement)
var MIME_TYPE = "image/png";
var imgURL = canvasElement[0].toDataURL(MIME_TYPE);
var dlLink = document.createElement('a');
dlLink.download = fileName;
dlLink.href = imgURL;
dlLink.dataset.downloadurl = [MIME_TYPE, dlLink.download, dlLink.href].join(':');
document.body.appendChild(dlLink);
dlLink.click();
document.body.removeChild(dlLink);
},