downLoadFile (url, name) { this.xhr = new XMLHttpRequest() this.xhr.open('GET', url, true) this.xhr.responseType = 'blob' var vmThis = this this.xhr.onload = () => { ) { ) { let file = this.xhr.response let fileName = name if ('msSaveOrOpenBlob' in n
在异步请求中要返回文件流,不能使用JQuery,因为$.ajax,$.post 不支持返回二进制文件流的类型,可以看到下图,dataType只支持xml,json,script,html这几种格式,没有blob类型.所以只能选择使用原生Ajax XMLReques对象进行处理 前端代码 function output() { var branchCode = $("#currentBranchCode").val(); var transDate = $("#currentT