-1

我正在尝试从 jQuery Mobile 开始,但是当我尝试创建带有叠加幻灯片的左侧面板时,我被卡住了。这是我的代码:

<!DOCTYPE html>
<html>
 <head>
 <meta charset="UTF-8">
 <title>- test-</title>
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.css" />
 <script type="text/javascript" src="http://code.jquery.com/jquery-1.5.2.min.js">  </script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.js"></script>
 </head>
 <body>
  <div data-role="page">
  <div data-role="panel" id="testPanel" data-theme="e" data-position="left" data-display="overlay">
    <h3>Default panel options</h3>
    <p>This panel has all the default options: positioned on the left with the reveal display mode. The panel markup is <em>before</em> the header, content and footer in the source order.</p>
    <p>To close, click off the panel, swipe left or right, hit the Esc key, or use the button below:</p>
</div>
<div data-role="header">
    <h1>test</h1>
    <a href="#testPanel" data-role="button" data-icon="plus" data-iconpos="notext">Contact</a>
</div>
<div data-role="content">
</div>
<div data-role="footer" data-position="fixed">
    <h4>Copyright 2013 - All Rights Reserved -</h4>
</div>
</div>
</body>
</html>

它不起作用,当我单击链接按钮时,我收到此消息“加载页面错误”,并且我的面板的内容已经显示在页面中。谢谢你的帮助!

4

3 回答 3

2

似乎您正在使用jQueryjQuery Mobile框架的过时版本。我建议更新到最新版本。

这是使用 jQuery 1.9.1 和 jQuery Mobile 1.3.1 使用相同标记的工作演示

于 2013-07-03T06:00:01.250 回答
1

JQM 1.3 版本中引入了滑动面板。所以它不适用于其他版本。将 jQuery 1.7.2- 1.9.1 用于 JQM 1.3

有关详细信息,请参阅博客文章:http: //jquerymobile.com/blog/2013/02/20/jquery-mobile-1-3-0-released/

于 2013-07-03T06:02:26.190 回答
1

如果这不是您的索引页面,那么您很可能通过一个导航到它,<a href="yourpage.html>Page</a>在这种情况下,jquery 使用 Ajax 请求从一个页面导航到另一个页面,ajax 请求不会加载页面的全部内容,它只会加载<body>标签,即您在标签内编写的任何脚本都<head>不会被加载,因此页面将无法正常工作,您将面临错误来解决这个问题,您需要data-ajax="false"在属性内部使用<a>以防止 jquery mobile 使用 Ajax 调用来加载您的页面.

如果它是您的索引页面,那么请通过 js 代码,以便我们在所有情况下都可以检查它检查这些链接 以加载 jqm 页面以及 jqm中 ajax 调用的链接问题

于 2013-07-03T06:17:34.963 回答