|
@@ -485,9 +485,19 @@ export default {
|
|
|
|
|
|
try {
|
|
|
let blob = new Blob([exec], {type: 'application/vnd.ms-excel'})
|
|
|
- let url = URL.createObjectURL(blob)
|
|
|
- console.log(url)
|
|
|
- location.href = url
|
|
|
+ let href = URL.createObjectURL(blob)
|
|
|
+ console.log(href)
|
|
|
+ // location.href = url
|
|
|
+
|
|
|
+ // 谷歌浏览器 创建a标签 添加download属性下载
|
|
|
+ const downloadElement = document.createElement('a')
|
|
|
+ downloadElement.href = href
|
|
|
+ downloadElement.target = '_blank'
|
|
|
+ downloadElement.download = new Date().getTime() + '.xls'
|
|
|
+ document.body.appendChild(downloadElement)
|
|
|
+ downloadElement.click() // 点击下载
|
|
|
+ document.body.removeChild(downloadElement) // 下载完成移除元素
|
|
|
+ window.URL.revokeObjectURL(href) // 释放掉blob对象
|
|
|
} catch (e) {
|
|
|
console.error(e)
|
|
|
}
|