生成文件并下载

  function createAndDownloadFile(fileName, content) {
    var aTag = document.createElement('a');
    var blob = new Blob([content]);
    aTag.download = fileName;
    aTag.href = URL.createObjectURL(blob);
    aTag.click();
    URL.revokeObjectURL(blob);
}

 

posted @ 2020-09-10 11:27  cnchengv  阅读(194)  评论(0编辑  收藏  举报