Apache Cordova APK在Android上无法正常运行 [英] Apache cordova apk doesn't run properly on android

查看:51
本文介绍了Apache Cordova APK在Android上无法正常运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ajax访问php文件.

I am using ajax to access a php file.

$.ajax({
    type:"post",
    url: "http://192.168.0.111/hetazotakan/read.php",
    success: function(result){
    var data=JSON.parse(result);
    console.log(data);
    var place=document.getElementById("news_space");
    for(var i=data.length-1;i>=0;i--){
        place.innerHTML+=`<li class="one_third">
          <article><a href="#"><img src="${data[i].photo}"       style="height:240px;width:320px;" alt=""></a>
            <h6 class="heading">${data[i].title}</h6>
            <ul class="nospace meta">
              <li><i class="fa fa-user"></i> <a href="#">Admin</a></li>
              <li><i class="fa fa-tag"></i> <a href="#">${data[i].date}</a></li>
            </ul>
            <p>${data[i].body.slice(1, 100)+"..."}</p>
            <footer class="nospace"><a class="btn" id="news_${data[i].id}" onclick="open_news(this.id)">Full Story &raquo;</a></footer>
          </article>
        </li>`;
    }
  },
    error:function(){alert(2);}
});

当我使用可运行的浏览器运行它时,今天我尝试在android上运行它,但是成功功能无法正常运行,相反它发出了警报2.我已将cordova-plugin-whitelist安装到我的项目中,并试图授予其访问IP地址的权限,但没有成功.这是配置文件.

When I run it with the browser it works, today I tried to run it on android, but the success function didn't work, instead it alerted 2. I have installed cordova-plugin-whitelist to my project and tried to give it access to the IP address, but it didn't work. Here's the config file.

<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>HelloCordova</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <access origin="*" />
<access origin="*" />
<allow-navigation href="*"/>
    <access origin="http://192.168.0.111" />
    <access origin="http://192.168.0.111/*/*" />
    <allow-intent href="http://localhost" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
    <access origin="*" />
<allow-navigation href="*"/>
    <access origin="http://192.168.0.111" />
    <access origin="http://192.168.0.111/*/*" />
        <allow-intent href="market:*" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
</widget>

我不知道该怎么办,当我在google上的android设备上访问192.168.0.111/Hetazotakan/read.php地址时,它可以正常工作.截止日期不到12小时,如果可以的话,请帮帮我.

I don't know what else to do, when I access the 192.168.0.111/Hetazotakan/read.php address on my android device on google it works. The deadline is in less then 12 hours, help me if you can.

推荐答案

192.168.0.111 是本地网络地址.除非您计划在连接到本地网络时始终运行您的应用程序,否则它在现实世界中将无法正常工作.考虑一个域名.

192.168.0.111 is a local network address. Unless you plan to always run your app while connected to your local network, it wouldn't work in the real world. Consider a domain name.

这篇关于Apache Cordova APK在Android上无法正常运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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