import Cookie from 'js-cookie'
界面:
<a-button
slot="extra"
type="primary"
@click="exportFile"
><a-icon type="download" />导出</a-button>
js方法
exportFile() {
fetch('http://127.0.0.1:8765/course/exportCourse/33', {
method: 'GET',
headers: new Headers({
'Authorization': Cookie.get('Authorization')
}),
})
.then(res => res.blob())
.then(data => {
const blobUrl = window.URL.createObjectURL(data);
const a = document.createElement('a');
a.download = this.fileName+'.xlsx';
a.href = blobUrl;
a.click();
});
},