PhoneGap的 - 的Javascript不工作 [英] Phonegap - Javascript not working

查看:137
本文介绍了PhoneGap的 - 的Javascript不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想解释一下什么是使用Javascript不工作的意思,但我可以做的唯一的事情就是告诉大家,code是从来没有执行,不知道如何调试。

I'd like to explain what does "Javascript not working" mean, but the only thing I can do is tell that the code is never executing, and don't know how to debug.

让我们开始:我正在开发一个应用程序的PhoneGap - 在这个意义上,我没有一个控制台对象来检查

Let's start: I'm developing a Phonegap application - in that sense, I don't have a console object to check on.

这是我的index.html文件:

This is my index.html file:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="format-detection" content="telephone=no" />
        <!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
        <title>1001Carros</title>
    </head>
    <body>
        <script type="text/javascript" src="phonegap.js"></script>
        <script type="text/javascript" src="js/index.js"></script>
        <script type="text/javascript">
            app.initialize();
        </script>
        adaptandose a dispositivo ...
    </body>
</html>

这是我的javascript:

And this is my javascript:

var app = {
    // Application Constructor
    initialize: function() {
        switch(device.platform) {
            case "iPhone":
                location.href = "index-iphone.html"; break;
            case "Android":
            case "BlackBerry":
            case "BlackBerry WebWorks":
                location.href = "index-android.html"; break;
            default:
                location.href = "index-android.html";
        }
    }
};

我的意图是:加载文档时,初始化()被调用。这种方法将验证平台和重定向中选取适当的屏幕。

My intention is: when the document is loaded, initialize() is called. Such method would verify the platform and redirect to the appropiate screen.

当我运行我在模拟器应用程序(这最后追加?enableripple =科尔多瓦来我的网址),我得到phonegap.js不存在。如果是这样的问题,它似乎很容易解释为什么我没有被重定向。

When I run my app in the emulator (which finally appends ?enableripple=cordova to my url), I get that "phonegap.js" does not exist. If that's the problem, it seems easy to explain why I'm not being redirected.

然而,当我编译通过本地工具的应用(即的PhoneGap运行的Andr​​oid )这样的文件似乎在资产要创建目录(Android平台)。

However, when I compile the application via local tools (i.e. phonegap run android) such file seems to be created in the assets directory (in android platform).

:我如何调试这个问题?我使用的仿真器和替代地,三星Galaxy Tab 3.我想调试设备,看看问题是否与文件(因为它是在模拟器/纹波所示),或者是在其他地方。

Question: How can I debug this issue? I'm using the emulator and, alternatively, a Samsung Galaxy Tab 3. I would like to debug the device and see if the problem is with the file (as it is shown in the emulator/ripple) or is it elsewhere.

这将会是巨大的,如果有人用更多的经验可以帮助我,如果他们也有类似的问题,因为这是我的第一个PhoneGap的应用程序。

It'd be great if someone with more experience could help me if they had a similar problem since it's my first phonegap application.

推荐答案

有很多方法可以调试你的PhoneGap code在Android:

There are plenty of ways to debug your phonegap code on android:

这篇关于PhoneGap的 - 的Javascript不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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