gpt4 book ai didi

android - 用Cordova显示本地保存的图片

转载 作者:行者123 更新时间:2023-11-29 12:06:19 24 4
gpt4 key购买 nike



我正在使用 Cordova 开发 iOS 和 Android 移动应用程序,但我在保存和显示从相机或相机胶卷拍摄并保存在本地的照片时遇到了问题。

我已经看过关于这个主题的其他对话:
Save image in local storage phonegap
Capturing and storing a picture taken with the Camera into a local database / PhoneGap / Cordova / iOS

我正在使用这些对话中描述的脚本很好,但最终无法显示保存的图片。

我知道图片已成功保存在我 iPhone 上的永久文件夹中,我可以使用 iExplorer 软件在我的应用程序子文件夹中看到它们,例如:Documents/MyApp/cdv_photo_002.jpg

我在我的 localStorage 中保存本 map 片的完整路径并获得类似的东西:file:///var/mobile/Containers/Data/Application/4E70258E-8060-48A6/Documents/MyApp/cdv_photo_002.jpg

当我尝试将此路径放入 img src 时,没有显示任何内容,好像图片不存在或没有此路径...
如何显示本 map 片?

最佳答案

正如 Matthieu Marcé 指出的,这个问题的答案应该是:

the problem was about fetching the local system path, so i had to put the path in a local storage item using

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
function(fileSys) {
localStorage.setItem('_localsys',fileSys.root.toURL());
}
);

关于android - 用Cordova显示本地保存的图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34874246/

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