android - jQuery Mobile 无法与 PhoneGap 配合使用

标签 android html jquery-mobile cordova

我正在开发 PhoneGap应用程序并正在使用 jQuery Mobile 。上次我处理这个项目时,它看起来很棒,但现在 jQuery Mobile 停止工作了。这是怎么回事?

这是我的代码:

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" />
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.5.min.js"></script>
        <script type="text/javascript" src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script>
    </head>

    <body>
        <div id="page" data-role="page" data-theme="b">
            <div data-role="content">
            <h2>Login To Carpool Mobile</h2>
            <p align="right"><a href="registration.html" id="showregistration">Don't have an account? &rarr;</a></p>
                <form method="post" id="loginForm">

                    <label for="password">Email:</label>
                    <input class="required" type="text" name="username" id="username" placeholder="<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="86f3f5e3f4e8e7ebe3c6f2e7f4e1e3f2a8e5e9eb" rel="noreferrer noopener nofollow">[email protected]</a>">

                    <label for="password">Password:</label>
                    <input class="required" type="password" name="password" id="password" placeholder="password">

                    <input type="button" value="Login" id="submitButton" onClick="handleLogin()">
                </form>
            </div>
        </div>

        <script>
        $(document).ready(function() {
            checkPreAuth();
        });
        </script>
    </body>
</html>

最佳答案

PhoneGap 要求您在根目录的“config.xml”文件中手动设置/允许应用程序的各个方面。

我相信您正在寻找的解决方案是这一行:

<access origin="http://code.jquery.com" subdomains="true" />

您允许访问“http://code.jquery.com ”的外部资源并允许其所有子域。这意味着您刚刚解锁了 jquery mobile,这就是您想要的,如脚本标记所示:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script>

These "src" attributes are now seen as "subdomains" of http://code.jquery.com, which you have just successfully allowed!

关于android - jQuery Mobile 无法与 PhoneGap 配合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15510100/

相关文章:

在 ICS 上几分钟未调用 Android AsyncTask

java - 加载数十个纹理后应用程序崩溃

Android:如何将 Studio 连接到 Genymotion 虚拟设备?

jQueryMobile 删除输入字段

android - 在textview android上捏缩放

javascript - 实现密码切换功能

jquery - 使用 JQuery 在克隆之后和追加之前替换表 TD 中的类

javascript - 如何使用 jquery 设置文本字段所需的 html5

css - 如何控制 Jquery 移动控件组的大小?

jquery - 单击按钮本身后如何更改按钮颜色?