Android $http get-in-ionic无法在实际设备上运行,即使安装了cordova插件白名单
我正在创建一个ionic应用程序,它使用$HTTPGET从远程服务器获取json值。当我在浏览器上运行数据时,它会显示数据,而不是在真正的Android设备上。我还安装了Android $http get-in-ionic无法在实际设备上运行,即使安装了cordova插件白名单,android,angularjs,cordova,ionic-framework,Android,Angularjs,Cordova,Ionic Framework,我正在创建一个ionic应用程序,它使用$HTTPGET从远程服务器获取json值。当我在浏览器上运行数据时,它会显示数据,而不是在真正的Android设备上。我还安装了cordova插件白名单 这是我在index.html <html> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1, user
cordova插件白名单
这是我在index.html
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
<title></title>
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
<link href="css/ionic.app.css" rel="stylesheet">
-->
<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
<!-- your app's js -->
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
</head>
<body ng-app="starter">
<ion-nav-view>
</ion-nav-view>
</body>
</html>
config.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.ionicframework.xxxxxxx" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>XXXX</name>
<description>
An Ionic Framework and Cordova project.
</description>
<author email="you@example.com" href="http://example.com/">
Your Name Here
</author>
<content src="index.html"/>
<access origin="*"/>
<preference name="webviewbounce" value="false"/>
<preference name="UIWebViewBounce" value="false"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="SplashScreenDelay" value="2000"/>
<preference name="FadeSplashScreenDuration" value="2000"/>
<preference name="android-minSdkVersion" value="16"/>
<preference name="BackupWebStorage" value="none"/>
<feature name="StatusBar">
<param name="ios-package" value="CDVStatusBar" onload="true"/>
</feature>
<allow-navigation href="http://xxxx.com/*" />
</widget>
我还尝试卸载并重新安装了cordova插件白名单
,但没有任何改变
cordova插件删除cordova插件白名单
cordova插件添加cordova插件白名单
这些是控制台上显示的错误。大多数是404,如下所示:
Failed to load resource: net::ERR_NAME_NOT_RESOLVED
但这可能是因为
Refused to load the script 'http://localhost:35729/livereload.js?snipver=1' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-inline' 'unsafe-eval'".
(anonymous function) @ localhost:8100/?ionicplatform=ios:98
请帮忙。。提前感谢。我使用它作为我的元标记,它处理所有这些事情。试试这个,让我知道它有效
<meta http-equiv="Content-Security-Policy" content="default-src *; img-src *;style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'">
上次我找到了答案,但现在我就把它贴出来。我通常使用Ionic Lab运行我的android应用程序,但当我从控制台(
Ionic run android
)运行我的应用程序时,我注意到:
“将此版本的Cordova与旧版本的corodva android一起使用
正在被贬低。考虑升级到科尔多瓦-android@5.0.0或
更新的。”
所以我刚升级了我的cordova:
cordova platform remove android
cordova platform add android@5.X.X
然后它终于起作用了。你有什么错误吗??如果你发布了什么错误,那就好了。除此之外,其他错误只有404。拒绝加载脚本“”,因为它违反了以下内容安全策略指令:“script src‘self’‘unsafe inline’‘unsafe eval’。另外,我的cordova版本是6.5.0,我尝试将其降级为6.3.0。没发生什么事,你能在纳雷什找到我吗。suruvu@gmail.com,我们将在那里讨论
<meta http-equiv="Content-Security-Policy" content="default-src *; img-src *;style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'">
cordova platform remove android
cordova platform add android@5.X.X