我的项目是由Vue.js构建的,当我使用axios请求excel文件时出现了乱码。
使用POI在Java代码中生成excel,我将responseType设置为axios,但是下载的excel的内容只是未定义。
这是一些代码
// axios
this.axios({
method: 'post',
url: 'adaptive/downloadBuilding',
data: { value: JSON.stringify(this.paramForm), postType: 'param' },
responseType: 'blob'
}).then(res => {
let blob = new Blob([res], { type: 'application/vnd.ms-excel' })
let url = window.URL.createObjectURL(blob)
window.location.href = url
})
我希望能在excel中很好地显示下载的数据