vue-导出表格
1、下载表格(二进制)
exportExcel () { axios.get(url, { headers:{ "Admin_token":token }, responseType: 'blob', //二进制流 }).then(function (res) { // res为后端接口返回二进制流数据 if(!res) return const content = res const blob = new Blob([content], {type: 'application/vnd.ms-excel'}) const fileName = '下载表格'+ '.xls' if ('download' in document.createElement('a')) { // 非IE下载 const elink = document.createElement('a') elink.download = fileName elink.style.display = 'none' elink.href = URL.createObjectURL(blob) document.body.appendChild(elink) elink.click() URL.revokeObjectURL(elink.href) // 释放URL 对象 document.body.removeChild(elink) } else { // IE10+下载 navigator.msSaveBlob(blob, fileName) } }).catch(function (error) { console.log(error) }) }

浙公网安备 33010602011771号