这在谷歌浏览器中运行良好,但在我的代码中在下面提到的行中的Internet Explorer中出错。任何人都可以建议我需要做什么改变才能在IE中工作。
var file = new File([JSON.stringify($localStorage)], "somefile.txt", {type: "text/plain;charset=utf-8"});
答案 0 :(得分:3)
要解释该链接,IE 11不支持new File()
构造函数,因此您必须使用blob。这是一个基本的例子:
var myArr = ["Hello", "World", "123", "Howdy"];
var b = new Blob([JSON.stringify(myArr)], {type: "text/plain;charset=utf-8"});
window.navigator.msSaveBlob(b, "OutputFile.txt");
现在您应该收到下载提示。