jquery mobile未在phonegap app中加载

时间:2014-07-30 19:02:56

标签: 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运行应用程序运行ios并且构建成功时,我得到附加的图像输出:

enter image description here

按钮应如下所示:

enter image description here

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

enter image description here

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

谢谢,

1 个答案:

答案 0 :(得分:1)

cordova.js脚本标记应位于标题中。您还需要检查应用程序的cordova.js目录中是否存在www文件。我重写了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>