作者 RuoYi

BLOB下载时清除URL对象引用

@@ -32,9 +32,11 @@ export function resolveBlob(res, mimeType) { @@ -32,9 +32,11 @@ export function resolveBlob(res, mimeType) {
32 var result = patt.exec(contentDisposition) 32 var result = patt.exec(contentDisposition)
33 var fileName = result[1] 33 var fileName = result[1]
34 fileName = fileName.replace(/\"/g, '') 34 fileName = fileName.replace(/\"/g, '')
  35 + aLink.style.display = 'none'
35 aLink.href = URL.createObjectURL(blob) 36 aLink.href = URL.createObjectURL(blob)
36 aLink.setAttribute('download', fileName) // 设置下载文件名称 37 aLink.setAttribute('download', fileName) // 设置下载文件名称
37 document.body.appendChild(aLink) 38 document.body.appendChild(aLink)
38 aLink.click() 39 aLink.click()
  40 + URL.revokeObjectURL(aLink.href);//清除引用
39 document.body.removeChild(aLink); 41 document.body.removeChild(aLink);
40 } 42 }