Vue axios 下载 excel文件

·  阅读 30
Vue axios 下载 excel文件
downLoadFile(data.fileId)
        .then(res => {
          const blob = new Blob([res], {
            type: "application/vnd.ms-excel"
          });
          const fileName = data.fileName;
          if (window.navigator.msSaveOrOpenBlob) {
            navigator.msSaveBlob(blob, fileName);
          } else {
            var link = document.createElement("a");
            link.href = window.URL.createObjectURL(blob);
            link.download = fileName;
            link.click();
            // 释放内存
            window.URL.revokeObjectURL(link.href);
          }
        })
        .catch(() => {});
}
    ```
复制代码
分类:
前端
标签:
收藏成功!
已添加到「」, 点击更改