(function(w){
        w.downloadBlob = function download(blob,fileName){
            
            const url = window.URL.createObjectURL(blob);
            const a = document.createElement('a');
            a.style.display = 'none';
            a.href = url;
            a.download = fileName;
            document.body.appendChild(a);
            a.click();
        }
    })(window);
    const downloadButton = document.querySelector('a#download');
    downloadButton.onclick = function(){
        var blob = new Blob(['我是Blob'],{type: 'text/html'});
        downloadBlob(blob,'test.html');
    };

文件类型:

html:text/html
pdf:application/pdf

相关文章:

  • 2022-12-23
  • 2021-12-03
  • 2021-08-14
  • 2021-05-17
  • 2021-12-10
猜你喜欢
  • 2022-12-23
  • 2021-09-15
  • 2021-06-25
  • 2022-12-23
  • 2021-12-06
  • 2021-05-24
  • 2021-06-29
相关资源
相似解决方案