标签:script 测试 export amp array fileread bsp rip result
经过测试第二种方法可以保存更多的文本不至于卡死
var saveTextAsFile1 = function (text, fileName, success, error) { var data = text; if (!(text instanceof Array)) { data = [text]; } var file = new File(data, fileName); var reader = new FileReader(); reader.readAsDataURL(file); reader.onload = function (r) { var url = reader.result; downLoadFile(url, fileName, function () { success && success(); }, function () { error && error(); }); }; } /** * 下载文件 * @param {string, Array} text * @param {string} fileName * @param {function} success * @param {function} error */ var saveTextAsFile = function (text, fileName, success, error) { var data = text; if (!(text instanceof Array)) { data = [text]; } var urlObject = window.URL || window.webkitURL || window; var export_blob = new Blob(data); var url = urlObject.createObjectURL(export_blob); downLoadFile(url, fileName, function () { success && success(); }, function () { error && error(); }); }
标签:script 测试 export amp array fileread bsp rip result
原文地址:https://www.cnblogs.com/Leechg/p/9501014.html