📜  javascript 写入文本文件堆栈溢出 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:03.685000             🧑  作者: Mango

代码示例1
var textFile = null,
  makeTextFile = function (text) {
    var data = new Blob([text], {type: 'text/plain'});

    // If we are replacing a previously generated file we need to
    // manually revoke the object URL to avoid memory leaks.
    if (textFile !== null) {
      window.URL.revokeObjectURL(textFile);
    }

    textFile = window.URL.createObjectURL(data);

    // returns a URL you can use as a href
    return textFile;
  };