我正在使用condova 6.0和Ionic ver 1.7.14,设计一个Android移动应用程序,可以连接互联网连接。在Ionic Lab上,它工作正常,但是当我生成Android应用程序并安装在我的Galaxy S4上时,无法连接到互联网。我已经查看了一些论坛,我正在使用 cordova 白名单,并向我的 config.xml 文件添加了一些额外的属性,但仍然不起作用。
在我的配置.xml文件中
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.ionicframework.viclab151106" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>VicLab</name>
<description>
An Ionic Framework and Cordova project.
</description>
<author email="caribesoft@gmail.com" href="http://caribesoft.net/">
Victor Rodriguez
</author>
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<allow-navigation href="data:*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<access origin="*" />
<content src="index.html"/>
<access origin="*"/>
<preference name="webviewbounce" value="false"/>
<preference name="UIWebViewBounce" value="false"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="android-minSdkVersion" value="16"/>
<preference name="BackupWebStorage" value="none"/>
<feature name="StatusBar">
<param name="ios-package" value="CDVStatusBar" onload="true"/>
</feature>
</widget>`enter code here`
另外,这是我的索引.html文件:
<!DOCTYPE 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>VicLab</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>`enter code here`
<script src="js/controllers.js"></script>
<script src="js/whitelist.js"></script>
</head>
<body ng-app="starter">
<ion-nav-view></ion-nav-view>
</body>
</html>
提前感谢您的任何帮助!
我正在使用这个元,它运行良好。也许这是你的问题
<meta http-equiv="Content-Security-Policy" content="img-src 'self' data:; default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
另外,这是配置.xml部分
<allow-navigation href="*" />
<allow-intent href="*" />
<access origin="*" />
我没有使用Ionic,但我认为它会是一样的
请注意:此答案使用不受限制的白名单过滤器 - 仅用于开发。
此示例不安全。由你来保护您的应用。
此外,您的应用程序可能会被谷歌和苹果拒绝。