Vue Cli 3 + Axios下载Excel文件时如何解决乱码问题?

时间:2019-04-22 06:52:05

标签: javascript vue.js axios

我的项目是由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中很好地显示下载的数据

0 个答案:

没有答案