其实很简单,
首先需要两个js文件
直接上代码,几行就解决了
<a id="example1" onclick="exportGrid()" >导出图表</a>
//导出图表 function exportGrid() { html2canvas($("#exportGrid"), { allowTaint: true, taintTest: false, onrendered: function (canvas) { //canvas.id = "mycanvas"; //document.body.appendChild(canvas); //生成base64图片数据 var url = canvas.toDataURL(); //以下代码为下载此图片功能 var triggerDownload = $("<a>").attr("href", url).attr("download", (new Date()).getTime() + "girds.png").appendTo("body"); triggerDownload[0].click(); triggerDownload.remove(); } }); }
解决了你的问题的话,点个赞呗