按照 docs 中所述在 config.xml 中设置 errorUrl 时,我会收到一个错误告诉我
CordovaWebViewImpl: showWebPage: Refusing to load URL into webview since it is not in the <allow-navigation> whitelist. URL=error.html
我会看到默认的 Android 错误页面。
最佳答案
对我来说,将网址更改为
<preference name="ErrorUrl" value="file:///android_asset/www/error.html" />
成功了。您应该在 android 平台部分添加此值,因为这是 android 特定的。
另外请确保未设置
<allow-intent href="*" />
否则您会看到一条错误,告诉您没有找到处理 Intent 的 Activity
ActivityNotFoundException: No Activity found to handle Intent
如果您需要允许网页作为 Intent ,请考虑添加
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
相反。
关于javascript - Cordova 配置中的 errorUrl 在 Android 上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51192735/