vue blob流下载zip文件
asset_zip(this.delarr).then((res) => {const content = res.dataconst blob = new Blob([content],{type:"application/zip"})var timestamp = (new Date()).valueOf();const fileName = t...
·
asset_zip(this.delarr).then((res) => { const content = res.data const blob = new Blob([content],{type:"application/zip"}) var timestamp = (new Date()).valueOf(); const fileName = timestamp+'.zip' if ('download' in document.createElement('a')) { // 非IE下载 const elink = document.createElement('a') elink.download = fileName elink.style.display = 'none' elink.href = window.URL.createObjectURL(blob) document.body.appendChild(elink) elink.click() window.URL.revokeObjectURL(elink.href) // 释放URL 对象 document.body.removeChild(elink) } else { // IE10+下载 navigator.msSaveBlob(blob, fileName) } })
不能用base64转成blob,不然会文件大小对里边没东西,下载其他类型修改type,
更多推荐
已为社区贡献12条内容
所有评论(0)