使用FileSaver.js
引入 FileSaver.js
下载JSON
var blob = new Blob([JSON.stringify(data)], { type: "" });
saveAs(blob, "hello.json");
下载TXT
var blob = new Blob([JSON.stringify(data)], {
type: "text/plain;charset=utf-8"
});
saveAs(blob, "hello.txt");
评论