思路很简单,就是利用Blob、URL.createObjectURL()方法和<a> 便签的HTML5新属性download来模拟远端文件下载保存。下面直接上代码
savePath: function(){ var me = this; if(!me.curve){ $.uitools.alertDlg("Path还没有定义,请先定义路径!"); return; } var json = me.pathToJson(); var blob = new Blob([json]); var url = URL.createObjectURL(blob); var a = document.createElement("a"); a.setAttribute('download','path.json'); a.setAttribute('href',url); document.body.appendChild(a); a.click(); a.remove(); },
标签:me,javascript,download,json,createObjectURL,Blob,var,客户端 From: https://www.cnblogs.com/dajianshi/p/16771836.html