js文件下载


import request from '@/router/axios'

downfiles(uri) {
return request({ url: uri, method: 'get', responseType: 'blob', timeout: 1800000, }).then((response) => { // 处理返回的文件流 const blob = response.data var filename = '文件.xlsx' const link = document.createElement('a') link.href = URL.createObjectURL(blob) link.download = filename document.body.appendChild(link) link.click() window.setTimeout(function() { URL.revokeObjectURL(blob) document.body.removeChild(link) }, 0) }) }
原文地址:https://www.cnblogs.com/chensv/p/14735243.html