js关于Blob对象的使用

Bolb可以用来改变一个文件的类型

 

// 下载导出内容
export function downloadFile(data, config = {}) {
  const aLink = document.createElement("a");
  let blob = new Blob([data], {
    type: (config as any).type || "application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  })
  aLink.href = URL.createObjectURL(blob);
  aLink.download = (config as any).name;
  document.body.appendChild(aLink);
  aLink.click();
  document.body.removeChild(aLink);
}
原文地址:https://www.cnblogs.com/web-aqin/p/13863113.html