function axgetdata(url,params){
axios({
method: ‘get’,
url: url,
params: params,
responseType: ‘blob’
}).then((res) => {
const link = document.createElement('a') let blob = new Blob([res.data],{type: 'application/vnd.ms-excel'}); //获取heads中的filename文件名 let temp = res.headers["content-disposition"].split(";")[1].split("filename=")[1]; //对文件名乱码转义--【Node.js】使用iconv-lite解决中文乱码 let iconv = require('iconv-lite'); iconv.skipDecodeWarning = true;//忽略警告 let fileName = iconv.decode(temp, 'gbk'); console.log('fileName_',fileName) // return link.style.display = 'none' link.href = URL.createObjectURL(blob); link.setAttribute('download', fileName) document.body.appendChild(link) link.click() document.body.removeChild(link)
}).catch(error => {
//console.log(error);
});