<el-button type="primary" @click="exportXq">导出</el-button>
const exportXq = () => { fetch(`/index/exportScoreRecord?sid=${xqSid.value}`, { method: 'GET', headers: { token: localStorage.getItem('token'), }, }).then(res => { const link = document.createElement('a');// 创建a标签 link.download = "加减分详情表.xlsx";// a标签添加属性 link.style.display = 'none'; link.href = res.url; document.body.appendChild(link); link.click();// 执行下载 document.body.removeChild(link);// 释放标签 }) }
对大佬们来说可能很容易 但是对于我这个刚入行的小白来说不是那么容易的嘿嘿 毕竟之前没有写过嘛 也是看了很多才写出来的 只是想记录一下以后用到也方便查找 如果大家看到 希望对大家有帮助哦~