export default (url, options) => {
options.timeout = 180000;//毫秒
options.responseType = 'blob';//毫秒
return request(
url,
options
).then(res => {
if('msSaveOrOpenBlob' in navigator){//兼容ie
var data= res;//获取响应
var blob = new Blob([data], {type: 'application/vnd.ms-excel'});
window.navigator.msSaveOrOpenBlob(blob, options.data.fileName+".xls");
}else{
var blob = new Blob([res], { type: 'text/plain,charset=UTF-8' });
var url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.style.display = 'none';
link.download = options.data.fileName+".xls";
link.href = url;
link.click()
document.body.removeChild(link)
}
}).catch(err => ({ err }));
}
前端解析excel文件流并下载(兼容ie)
最新推荐文章于 2024-09-14 20:26:42 发布