require
doesn't exist on the browser/client side. Also, you cannot use fs
as well, it should be implemented on the back-end side. Please use the following approach -
function download(filename, json) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + JSON.stringify(json));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…