//画布生成Img 的其他属性定义详情查看gojs api,
myDiagram.makeImage();
//通过gojs API获取画布的img对象
img = myDiagram.makeImage({scale: 1,});
// 将图片的src属性作为URL地址
var url = img.src;
var a = document.createElement('a');
var event = new MouseEvent('click');
a.download = '下载图片名称';
a.href = url;
a.dispatchEvent(event);
//如果节点过多,makeImage生成清晰度不高可以考虑生成svg
// When the blob is complete, make an anchor tag for it and use the tag to initiate a download// Works in Chrome, Firefox, Safari, Edge, IE11function myCallback(blob) {var url = window.URL.createObjectURL(blob);var filename = "mySVGFile.svg";var a = document.createElement("a");a.style = "display: none";a.href = url;a.download = filename;// IE 11if (window.navigator.msSaveBlob !== undefined) {window.navigator.msSaveBlob(blob, filename);return;}document.body.appendChild(a);requestAnimationFrame(function() {a.click();window.URL.revokeObjectURL(url);document.body.removeChild(a);});}//生成svg 并下载function makeSvg() {var svg = myDiagram.makeSvg({ scale: 1, background: "white" });var svgstr = new XMLSerializer().serializeToString(svg);var blob = new Blob([svgstr], { type: "image/svg+xml" });myCallback(blob);}