繁体   English   中英

带有jQuery Mobile“ Hello World”的Phonegap无法正常工作

[英]Phonegap with jquery mobile “hello world” not working

只是试图通过phonegap来使jquery移动触发,但是我无法让我的世界触发。

所有对Js的引用都是正确的。

<!DOCTYPE html>
<html>
  <head>
  <title></title>

    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />

    <meta charset="utf-8">
    <link rel="stylesheet" href="style.css" type="text/css" media="screen" charset="utf-8">

        <script type="text/javascript" charset="utf-8" src="phonegap-1.1.0.js"></script>
        <script type="text/javascript" charset="utf-8" src="jquery.js"></script>
        <script type="text/javascript" charset="utf-8" src="jquery_mobile.js"></script>


    <script type="text/javascript">
    document.addEventListener("deviceready", onDeviceReady, false);


    function onDeviceReady() {
      $(document).ready(function() {
         $(document).bind("deviceready", function(){
             navigator.notification.alert("hello world");
         });
      });
    }

    </script>
  </head>
  <body>

  </body>
</html>

尝试这个:

<!DOCTYPE HTML>
<html>
  <head>
    <meta name="viewport" content="width=320; user-scalable=no" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
     <title>Hello With JQuery Mobile</title>
      <link rel="stylesheet" href="jquery.mobile/jquery.mobile-1.0rc1.min.css" type="text/css" charset="utf-8" />
      <script type="text/javascript" src="jquery.mobile/jquery-1.6.4.min.js"></script>
      <script type="text/javascript" charset="utf-8" src="phonegap-1.1.0.js"></script>
      <script type="text/javascript" src="jquery.mobile/jquery.mobile-1.0rc1.min.js"></script>

    <script type="text/javascript">
        var onDeviceReady = function() {
            alert("OnDeviceReady fired.");
        };

        function init() {
            document.addEventListener("deviceready", onDeviceReady, true);
        }
    </script>

  </head>
  <body onload="init();">

  </body>
</html>

您是否在Xcode中的html和js ar中包含了参考?

您应该尝试通过在html主体中放置一些内容来开始调试,并查看在编译和运行时是否出现该内容。

尝试像这样删除addEventListener和Function:

<script type="text/javascript">
    $(document).ready(function(){
        $(document).bind('deviceready', function(){
            navigator.notification.alert("hello world");
        });
    });
</script>

无需两次收听“ deviceready”。 该文档将首先准备就绪,然后再准备JQM触发设备。

希望对您有所帮助!

我有一个类似的问题。 注释掉jquery或jquerymobile引用导致该应用程序正常工作,但我无法在标头中同时使用它。 这两个文件都位于phonegap的www文件夹中。 我什至尝试从jquery.com引用代码,但是没有用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM