Vue front-end Blob file stream download

First request the data to set the responseType: 'blob' in the format of the other unchanged
insert image description here

The format returned by the backend is text/xml
insert image description here
and then manipulate data

    //数据转换为文件下载
                    var elink = document.createElement('a')
                    elink.download = '文件名称.zip'
                    elink.style.display = 'none'
                    var blob = new Blob([res.data], { type: 'application/zip' })
                    elink.href = URL.createObjectURL(blob)
                    document.body.appendChild(elink)
                    elink.click()
                    document.body.removeChild(elink)

insert image description here

Guess you like

Origin blog.csdn.net/weixin_48164217/article/details/118385842