Download package axios
// 下载数据 export const downloadFile = (id) => { return axios.request({ url: '/file-manage/file/download/' + id, method: 'get', responseType: 'blob' }) }
Incoming downloaded file name, file id to download the corresponding stream file format
// 下载文件 downloadFile (filename, id) { downloadFile(id).then(res => { console.log(res) if (!res) { return } let url = window.URL.createObjectURL(res.data) let link = document.createElement('a') link.style.display = 'none' link.href = url link.setAttribute('download', filename) document.body.appendChild(link) link.click() }).catch(err => { console.log(err.message) }) },