html - about:blank#blocked 在浏览器中下载文件时
问题描述
我正在尝试从本地服务器下载文件(也许将来我需要在其他服务器上这样做)。当我单击链接以在浏览器中下载文件时,会出现此消息“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 扩展来启用呼叫请求。扩展名是允许控制允许来源。
谢谢。
解决方案
推荐阅读
- parsing - 如何使用 ansible 从显示版本(cisco ios)解析元数据
- python - Python 脚本在 VSC 中有效,但在手动启动时无效
- r - R中的优化,对优化参数的总和和类型有约束
- python - 在python的for循环中关闭图形
- python - PyCharm 样式的文档字符串,包含带有 `>>>` 的代码
- node.js - 在 typescript 节点项目中使用 monorepo 样式测试目录时,ts-jest 找不到类型信息
- windows - 线程的上下文保存在哪里,是否可以通过编程方式访问(无需修改内核)?
- printing - 带有 Zebra ZM600 的 Ghostscript
- debugging - Firefox 调试,从智能手机上的台式电脑打开 localhost
- python - 在 TKinter GUI 中使用线程