Cordova Config 中的 errorUrl 在 Android 上不起作用



在配置中设置错误URL时.xml如文档中所述,我会收到一个错误告诉我

CordovaWebViewImpl: showWebPage: Refusing to load URL into webview since it is not in the <allow-navigation> whitelist. URL=error.html

我会看到默认的安卓错误页面。

对我来说,将网址更改为

<preference name="ErrorUrl" value="file:///android_asset/www/error.html" />

工作。您应该在 android 平台部分添加此值,因为这是特定于 android 的。

还要确保不要设置

<allow-intent href="*" />

否则,您将看到一条错误消息,告诉您未找到处理该意图的活动

ActivityNotFoundException: No Activity found to handle Intent

如果需要允许网页作为意图,请考虑添加

<allow-intent href="http://*/*" /> <allow-intent href="https://*/*" />

相反。

最新更新