ios - iOS错误无法加载资源:不支持的URL
问题描述
我正在使用 chrisben imgcache.js 插件来缓存图像,
自从更改为 WKWebview 后,此插件已停止为我工作。我已切换到在 Android 上运行良好的 v2.1.1。我正在使用带有以下插件的 Cordova
科尔多瓦插件 wkwebview 引擎:1.2.1 科尔多瓦插件 wkwebview 文件 xhr:2.1.4
控制台记录的以下内容表明文件已正确下载/存储,但在获取时失败。
> [Log] INFO: Download complete:
> file:///Users/shadow4768/Library/Developer/CoreSimulator/Devices/3965C47C-7718-48C3-82ED-DF9A2CCB3989/data/Containers/Data/Application/3BFC0F90-F7D4-4DFA-8648-0F440929F835/Library/NoCloud/imgcache/5b1950b1ee383f3fdd0e51bf84dfdbd505006d79
> (cordova.js, line 1540) [Log] INFO: Cached file size: 37161
> (cordova.js, line 1540) [Log] INFO: current size: 2533404 (cordova.js,
> line 1540) [Log] INFO: com.apple.MobileBackup metadata set
> (cordova.js, line 1540) [Log] INFO: File
> getdocument?documentid=41623&width=300 loaded from cache (cordova.js,
> line 1540) [Error] Failed to load resource: unsupported URL
> cdvfile://localhost/library-nosync/imgcache/91c59e590d88a60c252d8281aa165be35a7d5798
我发现的唯一解决方案与离子有关,
我最初认为下面的代码是一个修复程序,以实现它可能与我正在使用的不兼容,因为现在只有一些功能可以工作。
ImgCache.getCachedFileURL(src,
(originalUrl, cacheUrl) => {
const file = new File();
const cacheFileUrl = cacheUrl.replace('cdvfile://localhost/persistent/', file.documentsDirectory);
const localServerFileUrl = cacheFileUrl.replace('file://', 'http://localhost:8080');
//localServerFileUrl contains the loadable url
resolve(localServerFileUrl);
},
(e) => {
console.error('img-cache-error:', e);
reject(e)
});
任何关于我如何解决这个问题的想法都将不胜感激。
解决方案
推荐阅读
- javascript - React Hooks 在声明之前从 useState 访问状态
- mysql - MySQL选择不同的运行编号(缺失编号)的列?
- symfony - 在教义-orm中自我加入:Symfony
- stata - 将因子变量添加到 esttab
- hbase - 如何在 Phoenix sqlline 中获取 md5sum 的十六进制字符串?
- javascript - 如果选中收音机,则 Kendo Ui 禁用列
- android - 遇到了问题。解锁设备后不调用 OnStart Onresume 方法
- php - 找不到 php-gds-session 类 LookupRequest
- unit-testing - Vala 中的单元测试
- r - 是否有用于刷新数据文件或数据框以自动获取最近更新的数据的 R 函数?