Commit 6da6fffa1d9a020bf098fad1c2681220c96af995
Committed by
GitHub
Merge pull request #1444 from liuyanshi/allow_use_Blob_download_csv
allow browser whose useragent contains Safari to use Blob for downloading csv
Showing
1 changed file
with
1 additions
and
2 deletions
Show diff stats
src/components/table/export-csv.js
| @@ -41,7 +41,7 @@ const csv = { | @@ -41,7 +41,7 @@ const csv = { | ||
| 41 | _getDownloadUrl (text) { | 41 | _getDownloadUrl (text) { |
| 42 | const BOM = '\uFEFF'; | 42 | const BOM = '\uFEFF'; |
| 43 | // Add BOM to text for open in excel correctly | 43 | // Add BOM to text for open in excel correctly |
| 44 | - if (window.Blob && window.URL && window.URL.createObjectURL && !has('Safari')) { | 44 | + if (window.Blob && window.URL && window.URL.createObjectURL) { |
| 45 | const csvData = new Blob([BOM + text], { type: 'text/csv' }); | 45 | const csvData = new Blob([BOM + text], { type: 'text/csv' }); |
| 46 | return URL.createObjectURL(csvData); | 46 | return URL.createObjectURL(csvData); |
| 47 | } else { | 47 | } else { |
| @@ -66,7 +66,6 @@ const csv = { | @@ -66,7 +66,6 @@ const csv = { | ||
| 66 | const link = document.createElement('a'); | 66 | const link = document.createElement('a'); |
| 67 | link.download = filename; | 67 | link.download = filename; |
| 68 | link.href = this._getDownloadUrl(text); | 68 | link.href = this._getDownloadUrl(text); |
| 69 | - link.target = '_blank'; | ||
| 70 | document.body.appendChild(link); | 69 | document.body.appendChild(link); |
| 71 | link.click(); | 70 | link.click(); |
| 72 | document.body.removeChild(link); | 71 | document.body.removeChild(link); |