post 方式 传json参数 下载excel
var params = getParams(); params.action = 'auditListExport'; var xhr = new XMLHttpRequest(); xhr.responseType = "arraybuffer"; xhr.open("POST", downloadUrl); xhr.onload=function(){ const blob = new Blob([this.response], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }); if ('download' in document.createElement('a')) { const link = document.createElement('a'); link.download = '审核结果.csv'; link.style.display = 'none'; link.href = URL.createObjectURL(blob); document.body.appendChild(link); link.click(); URL.revokeObjectURL(link.href); document.body.removeChild(link); } else { navigator.msSaveBlob(blob); } } xhr.setRequestHeader('Content-type','application/json'); xhr.send(JSON.stringify(params));