记一次,axios,jq,xhr获取后端,excel数据乱码
01: 低版本的jq,不支持二进制数据的解析 01: 版本3.X 02: 设置 xhrFields: { responseType: ‘blob’ }, $ . ajax ( { url : 'http://192.168.10.101:8089/Defect/exportDefectByQuery' , type : 'post' , contentType : 'application/json;charset=UTF-8' , xhrFields : { responseType : 'blob' } , cache : false , data : JSON . stringify ( { action : 'exportDefectByQuery' , current_user_id : "1" } ) , success : function success ( res , textStatus , jqXHR ) { var fileName = decodeURIComponent ( '待办列表' ) var fileType = '.xls' // 这里res.data是返回的blob对象 let blob = new Blob ( [ res ] , { type : 'application/vnd.ms-excel' } ) ; let