vue里面用到iframe下载文件,在调接口的时候报错401,后来经过排查发现请求的时候header少了个东西,现在需要往header加一个东西,但是用了好多方法都没成功,请大神指教。
//js
let url = process.env.BASE_API + '/api/register/download/' + idsString + '?downloadKey='
let iframe = document.createElement('iframe')
iframe.style.display = 'none'
iframe.src = url + this.downloadKey
iframe.onload = function () {
document.body.removeChild(iframe)
}
document.body.appendChild(iframe)
//html
<iframe v-if="ifShowIframe" v-show="false" id="show-iframe"
frameborder=0 name="showHere" scrolling=auto
:src="iframeSrc"></iframe>