【问题标题】:jquery mobile not loading in phonegap appjquery mobile未在phonegap应用程序中加载
【发布时间】:2014-07-30 19:02:55
【问题描述】:

我正在尝试学习如何同时使用 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 运行并且构建成功时,我得到了附加的图像输出:

而按钮应该是这样的:

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

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

谢谢,

【问题讨论】:

  • ui-btn-aui-btn-b 添加到锚点。
  • 另外,jquery-core 在哪里?
  • 您缺少 jQuery 参考。在 JQM 引用之前添加 jQuery,这应该可以解决未捕获的类型错误

标签: javascript jquery jquery-mobile cordova


【解决方案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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多