保存JS中JSON或TXT或图片等到本地
引入 FileSaver.js或FileSaver.min.js
来源
GitHub 中文介绍
下载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");
转载请注明原文地址: https://lol.8miu.com/read-32591.html