iOS中的UIWebview会出现问题。苹果将拒绝使用此应用程序。因此,我们决定将WKWebview用于我们的cordova ios应用程序。我安装了cordova-plugin-wkwebview-engine并在config.xml文件中添加了<preference name="WKWebViewOnly" value="true" />
。问题出在启动屏幕之后,它显示白色空白屏幕。
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>HelloCordova</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="[email protected]" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<plugin name="cordova-plugin-ionic-webview" spec="^4.1.3" />
<preference name="WKWebViewOnly" value="true" />
<engine name="ios" spec="~5.1.1" />
<plugin name="cordova-plugin-background-mode" spec="^0.7.3" />
<plugin name="cordova-plugin-badge" spec="^0.8.8" />
<plugin name="cordova-plugin-camera" spec="^4.1.0" />
<plugin name="cordova-plugin-device" spec="^2.0.3" />
<plugin name="cordova-plugin-geolocation" spec="^4.0.2" />
<plugin name="cordova-plugin-splashscreen" spec="^5.0.3" />
<plugin name="cordova-plugin-x-toast" spec="^2.7.2" />
</widget>
根据我的经验,它实际上不是白屏,而是具有白色背景的空白视图,cordova应用程序无法正确呈现,如果滚动,您可以看到下面的所有div视图。
[这似乎是新的iOS 13.4发行版上的cordova应用程序存在的问题,无论使用UIWebview还是WKWebview。
根据cordova文档:https://github.com/apache/cordova-plugin-wkwebview-engine/blob/master/README.md
必须添加这些权限
<feature name="CDVWKWebViewEngine">
<param name="ios-package" value="CDVWKWebViewEngine" />
</feature>
<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />
因此,请检查是否已添加它们,以及文档中所述的内容:“在iOS 9中,Apple已修复了iOS 8中存在的问题,该问题导致您无法使用file://加载区域设置文件,而必须诉诸于使用本地Web服务器。但是,您仍然无法使用file://中的XHR服务器上未启用CORS的协议。“
因此,如果您在版本8上进行测试,则存在问题,但是我认为由于我看到config.xml中的实现仍然不完整,因此请使用功能和首选项对其进行更新。
转到tsconfig.json
,并确保在compilerOptions
中将target
设置为es5
。我尝试了所有,只有这对我有用