response,二进制文件流下载
-
responseType: 'blob'
export function downloadNewProduct(parameter) {
return axios({
url: api.downloadNewProduct,
method: 'post',
responseType: 'blob',
data: parameter
});
}
-
转blob创建URL对象
let a = document.createElement('a');
let url = window.URL.createObjectURL(new Blob([res]));
// 创建url对象
a.href = url;
a.download = '测试.xlsx';
a.click();
// 释放url对象
window.URL.revokeObjectURL(url);
网友评论