<i-button type="primary" icon="md-log-out" @click="exportExcel()">导出</i-button>
exportExcel: function () {
var url = 接口;
var xhr = new XMLHttpRequest();
var fd = new FormData();
fd.append('sex', vm.table.sex) //请求传的参数
xhr.open('POST', url, true);//post请求,请求地址,是否异步
xhr.responseType = "blob"; // 返回类型blob
xhr.onload = function () {// 请求完成处理函数
if (this.status === 200) {
var blob = this.response;// 获取返回值
var a = document.createElement('a');
a.download = '文件名称.xls';
a.href = window.URL.createObjectURL(blob);
a.click();
}
};
// 发送ajax请求
xhr.send(fd);
},
585

被折叠的 条评论
为什么被折叠?



