前端处理后台传过来的apk流文件----移动端app

image.png

问题描述

后台返回的乱码(get请求)

阅读 3.1k
3 个回答

这个是后台没有正常的返回 content-type 吧..

你需要在新窗口打开请求的完整链接

新手上路,请多包涵

this.$api.danger

.getDownloadVersion({

                                    path:this.downPath,

                                    responseType:'blob'

                                })

.then(res=> {

leta=document.createElement('a')

letblob=newBlob([res], {

                                        type:'application/octet-stream'

                                    })

// 创建下载的链接

letobjectUrl=URL.createObjectURL(blob)

a.setAttribute('href',objectUrl)

// 下载文件名和文件类型

a.setAttribute('download',this.downPath)

// 点击下载

a.click()

// 下载完成移除元素

document.body.removeChild(a)

// 释放掉blob对象

URL.revokeObjectURL(objectUrl)

                                })

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题