javascript - jquery mobile 未在phonegap 应用程序中加载

标签 javascript jquery jquery-mobile cordova

我正在尝试学习如何一起使用 jQuery mobile 和phonegap。我有以下基本索引页:

<!DOCTYPE html>

<html>
    <head>
        <meta charset="utf-8" />
        <meta name="format-detection" content="telephone=no" />
        <meta name="msapplication-tap-highlight" content="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" />
        <link rel="stylesheet" type="text/css" href="css/index.css" />

        <link rel="stylesheet" type="text/css" href="css/jquery.mobile-1.4.3.css" />
        <link rel="stylesheet" type="text/css" href="css/jquery.mobile.external-png-1.4.3.css" />
        <link rel="stylesheet" type="text/css" href="css/jquery.mobile.icons-1.4.3.css" />
        <link rel="stylesheet" type="text/css" href="css/jquery.mobile.inline-png-1.4.3.css" />
        <link rel="stylesheet" type="text/css" href="css/jquery.mobile.inline-svg-1.4.3.css" />
        <link rel="stylesheet" type="text/css" href="css/jquery.mobile.structure-1.4.3.css" />
        <link rel="stylesheet" type="text/css" href="css/jquery.mobile.theme-1.4.3.css" />


        <title>UIAdv</title>
    </head>
    <body>
        <div class="app">
            <h1>Welcome to UIAdv</h1>
            <a href="#" class="ui-btn ui-btn-inline">Anchor</a>
        </div>
        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="js/jquery.mobile-1.4.3.js"></script>
        <script type="text/javascript" src="js/index.js"></script>
        <script type="text/javascript">
            app.initialize();
        </script>
    </body>
</html>

其中我有以下行,应该使用 jquery 库呈现按钮:

        <a href="#" class="ui-btn ui-btn-inline">Do Something</a>

当使用phonegap run ios运行应用程序并且构建成功时,我得到附加的图像输出:

enter image description here

而按钮应该如下所示:

enter image description here

当我在浏览器中打开index.html(在phonegap应用程序的目录中)时,我在控制台中看到以下内容:

enter image description here

我猜这就是导致问题的原因。我需要你的支持来解决这个第一次遇到的问题(对我自己)。我下载了所有 jQuery mobile zip 文件,并将所有文件放置在 PhoneGap 应用程序的相应文件夹中。

谢谢

最佳答案

cordova.js 脚本标记应位于 header 中。此外,您还需要检查应用程序的 www 目录中是否存在 cordova.js 文件。我已经重写了html文件。您可以使用下面的代码来测试您的 jquery 移动应用程序。快乐编码!

<html>
<head>
    <title>UIAdv</title>
    <meta charset="utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="msapplication-tap-highlight" content="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" />
    <!-- link rel="stylesheet" type="text/css" href="css/index.css" /-->

    <link rel="stylesheet" type="text/css" href="css/jquery.mobile-1.4.3.css" />
    <link rel="stylesheet" type="text/css" href="css/jquery.mobile.external-png-1.4.3.css" />
    <link rel="stylesheet" type="text/css" href="css/jquery.mobile.icons-1.4.3.css" />
    <link rel="stylesheet" type="text/css" href="css/jquery.mobile.inline-png-1.4.3.css" />
    <link rel="stylesheet" type="text/css" href="css/jquery.mobile.inline-svg-1.4.3.css" />
    <link rel="stylesheet" type="text/css" href="css/jquery.mobile.structure-1.4.3.css" />
    <link rel="stylesheet" type="text/css" href="css/jquery.mobile.theme-1.4.3.css" />

    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript" src="js/jquery.mobile-1.4.3.js"></script>
    <!-- script type="text/javascript" src="js/index.js"></script -->
    <!-- script type="text/javascript"> app.initialize(); </script -->
</head>
<body>
<div class="app">
    <h1>Welcome to UIAdv</h1>
    <a href="#" class="ui-btn ui-btn-inline">Anchor</a>
</div>
</body>
</html>

关于javascript - jquery mobile 未在phonegap 应用程序中加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25044864/

相关文章:

javascript - vue中如何更改词尾?

javascript - 对用户隐藏密码字段内容

javascript - 绘制后避免重排 css3 列

jquery-mobile - 移动页面的面包屑

jquery-mobile - jquery mobile 和 Durandal

jquery-mobile - AngularJS 和 jquery 移动版

javascript - AngularJS 指令参数 "ctrls"

javascript - 用 getElementById 填充数组

c# - 单选按钮值为空

JQUERY:如何按值选择选项?