浏览器本地导出文件
/**
* 导出文件
* @param data 数据
* @param name 文件名
*/
exportRaw: function(data, name) {
var urlObject = window.URL || window.webkitURL || window;
var export_blob = new Blob([data]);
var save_link = document.createElementNS("http://www.w3.org/1999/xhtml", "a")
save_link.href = urlObject.createObjectURL(export_blob);
save_link.download = name;
save_link.click();
},
实例:保存txt文件
//保存文本文件
saveFile: function(text) {
var name = 'download_.txt';
this.exportRaw(text, name);
},
标签:浏览器,name,Javascript,导出,window,link,var,save,data
From: https://www.cnblogs.com/cqpanda/p/16925845.html