我正在尝试从本地服务器下载文件(也许将来我需要在其他服务器上下载文件)。当我单击链接以在浏览器中下载文件时,出现以下消息“ about:blank#blocked”。
我正在使用axios和vue.js。 。 代码是这样的:
downloadItem(urlDoc) {
console.log(urlDoc);
axios({
method: 'get',
url: urlDoc,
responseType: 'arraybuffer',
}).then(function(response) {
let blob = new Blob([response.data], { type: 'image/png' })
let link = document.createElement('a')
link.href = window.URL.createObjectURL(blob)
link.download = 'image.png'
link.click()
})
}
以前,我添加了chrome扩展程序以能够发出呼叫请求。扩展名为allow-control-allow-origin。
谢谢。