📅  最后修改于: 2022-03-11 14:52:51.380000             🧑  作者: Mango
var textToSave = 'this is a test';
var hiddenElement = document.createElement('a');
hiddenElement.href = 'data:attachment/text,' + encodeURI(textToSave);
hiddenElement.target = '_blank';
hiddenElement.download = 'myFile.txt';
hiddenElement.click();