1旗芬、post請(qǐng)求返回二進(jìn)制文件如何生成excel并下載到本地
// res 為接口返回的數(shù)據(jù)
const content = res;
const blob = new Blob([content]);
const fileName = `test.xlsx`;
const a = document.createElement('a');
a.href = URL.createObjectURL(blob);
a.download = fileName;
document.body.appendChild(a);
a.click();
URL.revokeObjectURL(a.href);
document.body.removeChild(a);
2、post請(qǐng)求以formData格式上傳文件
const formData = new FormData();
formData .append('file', file);
axios.post('接口地址', formData , {
} )