这里采用的axios 进行的封装
return axios({
method: 'post',
url: options.url,
headers: {
'content-type': 'application/json',
Accept: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
},
responseType: 'arraybuffer',
data: options.params
}).then(function (res) {
if (res) {
const url = window.URL.createObjectURL(
**这儿有一个坑 post请求 有写成 res.data get 请求 直接是res**
new Blob([res.data], {
type: 'application/vnd.ms-excel'
})
)
const link = document.createElement('a')
link.href = url
link.setAttribute('download', options.text + '.xls')
document.body.appendChild(link)
link.click()
Message({
message: '导出成功',
type: 'success',
duration: 3000
})
} else {
Message({
message: '导出失败',
type: 'error',
duration: 3000
})
}
})
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。