js save data to json file and download

const content = JSON.stringify(data);//data为json格式的数据
var blob = new Blob([content],{type: "text/plain;charset=utf-8"});
saveAs(blob, "jsondata.json");

The saveAs() method needs to introduce the following js 

 <script  src="https://cdn.bootcss.com/FileSaver.js/2014-11-29/FileSaver.js"></script>

Guess you like

Origin blog.csdn.net/weixin_40841731/article/details/130528905