1、wkwebview 已内置集成,不再需要 cordova-plugin-wkwebview-engine
2、需要更新cordova-plugin-splashscreen插件。
因为 Splash Screen 已经集成到 cordova-ios@6 了,cordova-plugin-splashscreen@6.0.0 中已经移除了 ios 的代码
3、iPadOS 13 默认使用桌面布局,而不是移动布局。现在,可以在config.xml中配置<preference name="PreferredContentMode" value="xxx" />
来控制此行为。
xxx可取的值是mobile
和desktop
。
4、cordova-ios@6.1.0 支持配置使用 WKURLSchemeHandler 来加载本地html网页,以绕过 file://.../index.html
访问本地文件的各种限制。
只要在 config.xml 配置如下即可
<preference name="scheme" value="cdv" />
<preference name="hostname" value="localhost" />
但是,这样配置之后,cordova 加载本地网页的地址为 cdv://localhost/index.html
,由于“内容安全策略(Content Security Policy)”,这个路径访问的网页下,是无法展示 file://
路径的图片的,因为会报错
Not allowed to load local resource: file:///var/mobile/Containers/Data/Application/E09B7F43-B170-4435-A850-18277C597062/tmp/cache/avatar/7272b2c7-f7a8-4600-811d-6b7f2a3de3b3.jpg
解决方法
cordova 的 wkwebview 提供了一个方法来将 file://
路径转为 cdv://
地址(文档中没写)
window.WkWebView.convertFilePath('file:///var/mobile/Containers/Data/Application/E09B7F43-B170-4435-A850-18277C597062/tmp/cache/avatar/7272b2c7-f7a8-4600-811d-6b7f2a3de3b3.jpg')
得到一个如下的url
cdv://localhost/_app_file_/var/mobile/Containers/Data/Application/E09B7F43-B170-4435-A850-18277C597062/tmp/cache/avatar/7272b2c7-f7a8-4600-811d-6b7f2a3de3b3.jpg
这个url就可以放在 <img src>
上展示了