Commit 5993a1ed by 袁晓帅

修改下载文件不成功的问题

parent dcb26030
......@@ -184,14 +184,18 @@ export default {
this.$axios({
method: 'post',
url: '/carParking/carExport',
data:{},
data:{
c: 100,
p: 1
},
responseType:'blob',
headers: {
'Content-Type': 'application/json;charset=UTF-8', //设置请求头请求格式为JSON
token: window.sessionStorage.getItem('token'),
projectId: window.sessionStorage.getItem('projectId')
}
}).then(res => {
let blob = new Blob([res], {type: "application/vnd.ms-excel"}); // res就是接口返回的文件流了
let blob = new Blob([res.data], {type: "application/vnd.ms-excel"}); // res就是接口返回的文件流了
let objectUrl = URL.createObjectURL(blob);
window.location.href = objectUrl;
});
......
......@@ -52,6 +52,8 @@ axios.interceptors.response.use(function (response) {
alert('登录失效,请重新登录', '温馨提示')
router.push('/login')
return false
} else if (response.data.type === 'application/vnd.ms-excel') {
return response
} else {
// 在添加其他的错误码判断
if (response.data.msg) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment