解决a链接下载图片,跳至预览页
uploadCode () {
let a_link = document.createElement('a')
a_link.style.display = 'none'
a_link.href= this.formList.shop_code + '?response-content-type=application/octet-stream'
a_link.setAttribute("id", "codeLink")
a_link.setAttribute("download", "xxx")
document.body.appendChild(a_link)
a_link.click()
let objLink = document.getElementById('codeLink')
document.body.removeChild(objLink)
},
shop_code是后台返的图片链接,需要给链接后面拼接‘?response-content-type=application/octet-stream’即可