在我的Ionic应用程序中,每个$http POST
或GET
来电都会被阻止:
无法加载资源:net :: ERR_NAME_NOT_RESOLVED
它在Ipv4中工作正常但在我们在手机网络的APNS设置中选择Ipv6时显示错误。我该怎么办?
Config.xml文件
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.jio.smart.vehicle" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Name</name>
<description>

An Ionic Framework and Cordova project.

</description>
<author email="hi@ionicframework" href="http://ionicframework.com/">

Ionic Framework Team

</author>
<content src="index.html"/>
<access origin="*" subdomains="true"/>
<access origin="tel:*" launch-external="yes"/>
<access origin="cdvfile://*"/>
<allow-navigation href="*" />
<preference name="webviewbounce" value="false"/>
<preference name="UIWebViewBounce" value="false"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="android-minSdkVersion" value="16"/>
<preference name="loadUrlTimeoutValue" value="700000" />
<preference name="FadeSplashScreen" value="false"/>
<preference name="AndroidPersistentFileLocation" value="Compatibility"/>
<preference name="BackupWebStorage" value="none"/>
<preference name="SplashScreen" value="screen"/>
<preference name="android-windowSoftInputMode" value="adjustPan"/>
<preference name="AutoHideSplashScreen" value="false" />
<preference name="ShowSplashScreenSpinner" value="true"/>
<preference name="StatusBarOverlaysWebView" value="false"/>
<preference name="android-targetSdkVersion" value="20"/>
<hook type="before_run" src="hooks/appBeforeBuild.js" />
<feature name="StatusBar">
<param name="ios-package" value="CDVStatusBar" onload="true"/>
</feature>
<platform name="android">
<icon src="resources\android\icon\drawable-ldpi-icon.png" density="ldpi"/>
</platform>
<icon src="resources\android\icon\drawable-xhdpi-icon.png"/>
</widget>
答案 0 :(得分:0)
原因为什么GET和POST调用失败?
你错过了cordova白名单插件。它需要发出GET或POST请求。 安装命令
cordova插件添加cordova-plugin-whitelist
导航白名单
控制可以导航到WebView本身的URL。适用于 仅限顶级导航。
Quirks:在Android上它也适用于非http(s)方案的iframe。
默认情况下,仅允许导航到file:// URL。允许 其他URL,您必须在config.xml中添加标签:
<!-- Allow links to example.com -->
<allow-navigation href="http://example.com/*" />
<!-- Wildcards are allowed for the protocol, as a prefix
to the host, or as a suffix to the path -->
<allow-navigation href="*://*.example.com/*" />
<!-- A wildcard can be used to whitelist the entire network,
over HTTP and HTTPS.
*NOT RECOMMENDED* -->
<allow-navigation href="*" />
<!-- The above is equivalent to these three declarations -->
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<allow-navigation href="data:*" />
为了更好地理解请访问Official文档