【Vue】导出 下载excel 方案(点击下载,下载一个excel模板)
【Vue】导出 下载excel 方案(点击下载模板,下载一个excel模板)
exportExcel() {
// 防止文件乱码:responseType: 'arraybuffer'
userApi.sensitiveDown(this.queryParam, {responseType: 'blob'}).then(data => {
// (导出 下载excal)
const blob = new Blob([data], {type: 'application/vnd.ms-excel'});
const link = document.createElement('a')
link.style.display = 'none';
link.href = URL.createObjectURL(blob);
link.download = '敏感词模板.xlsx';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
})
},