gpt4 book ai didi

html - ElectonJs base64 image src-无法加载资源

转载 作者:行者123 更新时间:2023-12-03 12:42:02 24 4
gpt4 key购买 nike

在electronJs应用程序中,我试图使用动态创建的图像标签加载base64图像。使用insertAdjacentElement()方法将base64字符串附加到image标签,并将其附加到容器。我尝试使用模板字符串方法设置源,但没有成功。

当我运行该应用程序并执行添加图像的操作时。在控制台中,我得到了错误:
无法加载资源:net::ERR_FILE_NOT_FOUND
我尝试了许多base64字符串,但这始终是结果。

const imgTemplate: HTMLImageElement = document.createElement('img') as HTMLImageElement;
imgTemplate.src = base64; // declared variable container base64 string

if(this._appThumbnailContainer) {
this._appThumbnailContainer.insertAdjacentElement('beforeend', imgTemplate)
}

以下是DOM中html的屏幕。
enter image description here

此外,在开发人员工具的“网络”标签中,似乎正在抓取:

enter image description here

最佳答案

似乎您在src字符串中有一个额外的引号(src="'),请重新检查base64变量的内容。

关于html - ElectonJs base64 image src-无法加载资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59813033/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com