vue项目中导出excel文件
get导出通过window.location.href即可
post方法导出
getExcel(){ let params = { PageIndex: this.page, PageSize: this.pageSize, ...this.ruleForm } // api_ExportHotelOrderRpt(params) this.$https({ method: "post", header: { "Content-Type": "application/json" }, responseType: "blob", // 返回格式,默认json,可选arraybuffer、blob、document、json、text、stream url: `/Excel/ExportHotelOrderRpt`, data: params, }) .then((res) => { if(res){ console.log(res) let blob = new Blob([res.data], { type: "application/vnd.ms-excel", }); let url = window.URL.createObjectURL(blob); console.log(url); window.location.href = url; } }) .catch((error) => { console.log(error); }); },