将离子应用程序中的域列入白名单 [英] whitelisting a domain in ionic app

查看:101
本文介绍了将离子应用程序中的域列入白名单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读

http://ccoenraets.github.io/ionic-tutorial/build-ionic-project.html

并在浏览器上运行该应用

and ran the app on browser

ionic serve

并在android中使用

and in android using

ionic emulate android 

当我按照教程中的说明运行该应用程序时,它在我的chrome浏览器上运行良好,但是当我尝试在模拟器上运行时,我看不到任何数据,只是带有菜单的空白屏幕.我怀疑这是whilelist的问题,并添加了

When I run the app as instructed in tutorial, it works well on my chrome browser but when I try to run on emulator, I dont see any data, its just empty screens with menus. I suspect its the problem with whilelist and added

  <allow-navigation href="*" />

到我的/config.xml文件,但仍然无法正常工作,我当前的config.xml文件是

to my /config.xml file but it still doesn't work, My current config.xml file is

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.ionicframework.conference472350" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
  <name>conference</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="*" />
  <allow-intent href="*" />
  <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="BackupWebStorage" value="none"/>
  <preference name="SplashScreen" value="screen"/>
  <preference name="SplashScreenDelay" value="3000"/>
  <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"/>
    <icon src="resources/android/icon/drawable-mdpi-icon.png" density="mdpi"/>
    <icon src="resources/android/icon/drawable-hdpi-icon.png" density="hdpi"/>
    <icon src="resources/android/icon/drawable-xhdpi-icon.png" density="xhdpi"/>
    <icon src="resources/android/icon/drawable-xxhdpi-icon.png" density="xxhdpi"/>
    <icon src="resources/android/icon/drawable-xxxhdpi-icon.png" density="xxxhdpi"/>
    <splash src="resources/android/splash/drawable-land-ldpi-screen.png" density="land-ldpi"/>
    <splash src="resources/android/splash/drawable-land-mdpi-screen.png" density="land-mdpi"/>
    <splash src="resources/android/splash/drawable-land-hdpi-screen.png" density="land-hdpi"/>
    <splash src="resources/android/splash/drawable-land-xhdpi-screen.png" density="land-xhdpi"/>
    <splash src="resources/android/splash/drawable-land-xxhdpi-screen.png" density="land-xxhdpi"/>
    <splash src="resources/android/splash/drawable-land-xxxhdpi-screen.png" density="land-xxxhdpi"/>
    <splash src="resources/android/splash/drawable-port-ldpi-screen.png" density="port-ldpi"/>
    <splash src="resources/android/splash/drawable-port-mdpi-screen.png" density="port-mdpi"/>
    <splash src="resources/android/splash/drawable-port-hdpi-screen.png" density="port-hdpi"/>
    <splash src="resources/android/splash/drawable-port-xhdpi-screen.png" density="port-xhdpi"/>
    <splash src="resources/android/splash/drawable-port-xxhdpi-screen.png" density="port-xxhdpi"/>
    <splash src="resources/android/splash/drawable-port-xxxhdpi-screen.png" density="port-xxxhdpi"/>
  </platform>
</widget>

我正在使用chrome devtools调试应用程序,这是我在应用程序的控制台中收到的错误

I am debugging the app in chrome devtools and this is the error I get in console for the app

Failed to load resource: net::ERR_CONNECTION_REFUSED

推荐答案

有趣的是,我在开发应用程序时遇到了同样的问题.

Interestingly enough, I had the same issue while developing my app.

您是否正确安装了插件?您没有提到是否这样做.

Have you installed the plugin correctly? You didn't mention if you did.

您需要先安装 cordova白名单插件.我是通过 npm 完成的.

You need to install the cordova whitelist plugin first. I did this via npm.

我还在config.xml中添加了对资源的所有访问权限:

I also added all access to resources in my config.xml:

  <access origin="*" />
  <allow-intent href="*" />
  <allow-navigation href="*" />

但是,不建议这样做.而是允许访问该应用所需的资源.

Though, that is not recommended. Rather, allow access to the resources you need for the app.

这篇关于将离子应用程序中的域列入白名单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆