文件下载方法
This commit is contained in:
parent
bdac9282fc
commit
1f3ca6f5f2
|
@ -109,17 +109,14 @@ export default {
|
||||||
};
|
};
|
||||||
|
|
||||||
Vue.prototype.$fileDownload = function(url) {
|
Vue.prototype.$fileDownload = function(url) {
|
||||||
axios({
|
axios.get(url, {responseType: 'blob'})
|
||||||
method: 'get',
|
.then(response => {
|
||||||
url: url,
|
let fileName = window.decodeURI(response.headers['content-disposition'].split('=')[1]);
|
||||||
responseType: 'blob',
|
let link = document.createElement("a");
|
||||||
}).then(response => {
|
link.href = window.URL.createObjectURL(new Blob([response.data], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"}));
|
||||||
let fileName = window.decodeURI(response.headers['content-disposition'].split('=')[1]);
|
link.download = fileName;
|
||||||
let link = document.createElement("a");
|
link.click();
|
||||||
link.href = window.URL.createObjectURL(new Blob([response.data], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"}));
|
});
|
||||||
link.download = fileName;
|
|
||||||
link.click();
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Vue.prototype.$fileUpload = function(url, fileList, success, failure) {
|
Vue.prototype.$fileUpload = function(url, fileList, success, failure) {
|
||||||
|
@ -141,6 +138,5 @@ export default {
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue