javascript - TypeError:无法读取 ElectronJS 应用程序中未定义的属性“协议”
问题描述
我正在使用axios
并将fs
图像下载到本地目录。我正在使用 ElectronJS 和 VueJS 创建桌面应用程序。
async saveOptions() {
var currentLightbox = this.currentLightbox
var title = currentLightbox.data.title.replace(/\s/g, '_')
console.log(title)
var URL = currentLightbox.data.preview.images[0].source.url
fs.mkdir('images/', {recursive: true}, (err) => {
if (err) throw(err)
})
const Path = path.resolve('images/', `${title}.jpg`)
console.log(Path)
const writer = fs.createWriteStream(Path)
axios({
url: URL,
method: 'GET',
responseType: 'stream'
})
.then((response) => {
response.data.pipe(writer)
})
}
在下载时运行此功能,控制台给出以下错误:
Uncaught (in promise) TypeError: Cannot read property 'protocol' of undefined
at isURLSameOrigin (isURLSameOrigin.js?3934:57)
at dispatchXhrRequest (xhr.js?b50d:109)
at new Promise (<anonymous>)
at xhrAdapter (xhr.js?b50d:12)
at dispatchRequest (dispatchRequest.js?5270:52)
什么可能导致这种情况?
解决方案
推荐阅读
- data-warehouse - 在单个报告中结合附加和半附加事实
- angular - rxjs - ngrx - 一起(并行)执行多个运算符并并行调度多个动作
- xml - Sulu:在哪里放置自定义实体的 XML 文件?
- ios - 如何更改 M1 Mac 的 Cocoapods 源
- ajax - 从 AJAX 获取受 SSO 保护的 XHR 资源
- laravel - 如何在没有任何付款的情况下在 Braintree 客户中添加一个贝宝帐户?
- android - 如何在kotlin协程中通过ok http从url下载pdf
- continuous-integration - 如何在 GitLab CI/CD 中设置 TestCafe 工件?
- javascript - TypeError:无法读取未定义的属性“拆分”,如何检查参数是否可以拆分?
- laravel - Laravel - 如何解决 whereDate 函数问题