api文件:
export async function exportList(params){
return request({
responseType: ‘blob’,//需要指明blob
url: ‘/pms/goods/export’,
method: ‘post’,
data:params
})
}
需要导出文件的页面:
exportHandle(){
this.isExport=true;
exportList(this.dataForm).then(data=>{
this.isExport=false;
const binaryData = []
binaryData.push(data)
this.listUrl = window.URL.createObjectURL(new Blob(binaryData, { type: ‘application/vnd.ms-excel’}))
window.open(this.listUrl)
})
https://blog.csdn.net/guo187/article/details/109338440