Performance 使用jquery mobile在页面之间切换时性能不佳
在页面之间切换时,我遇到了性能问题。我去了各种论坛,添加了类似faskclick之类的内容 第一次,当我切换到不同的页面时,大约需要3-4秒,但从第二次开始,速度很快,例如1-1.5秒。现在,有时候,单击不起作用。在5次点击中,只有2-3次点击有效。我正在努力找出哪里出了问题 如果您能帮助我找出为什么单击不起作用,以及如何在使用jquery mobile时提高性能,这将非常有帮助。下面是我的代码片段Performance 使用jquery mobile在页面之间切换时性能不佳,performance,jquery-mobile,Performance,Jquery Mobile,在页面之间切换时,我遇到了性能问题。我去了各种论坛,添加了类似faskclick之类的内容 第一次,当我切换到不同的页面时,大约需要3-4秒,但从第二次开始,速度很快,例如1-1.5秒。现在,有时候,单击不起作用。在5次点击中,只有2-3次点击有效。我正在努力找出哪里出了问题 如果您能帮助我找出为什么单击不起作用,以及如何在使用jquery mobile时提高性能,这将非常有帮助。下面是我的代码片段 <html> <!-- head --> <head> &l
<html>
<!-- head -->
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="viewport" content="user-scalable=yes, width=device-width, initial-scale=1.0" />
<title>Project</title>
<link rel="stylesheet" href="StyleSheet/jquery.mobile-1.3.0.css" />
<script src="StyleSheet/jquery-1.8.2.min.js"></script>
<script src="StyleSheet/jquery.mobile-1.3.0.js"></script>
<script src="StyleSheet/fastclick.js"></script>
<script type="application/javascript">
$.mobile.defaultPageTransition = 'none';
$.mobile.transitionFallbacks.slideout = 'none';
window.addEventListener('load', function() {
new FastClick(document.body);
}, false);
$( document ).bind( "mobileinit", function() {
$.mobile.buttonMarkup.hoverDelay = 500
});
</script>
</head>
<body>
<div id="container">
<div data-role="page" id="HomePage" class="jqm-demos">
<div class="ui-body ui-body-b">
<a href="#SecondPage">CLick Me to go second page</a>
</div>
</div>
<div data-role="page" id="SecondPage" class="jqm-demos">
<div class="ui-body ui-body-b">
<br> <a href="#HomePage">CLick Me to go first page</a>
<div id="JQM" data-theme="b" data-content-theme="c"
data-role="collapsible" data-collapsed-icon="arrow-d"
data-expanded-icon="arrow-u">
<h3>
<span style="float: left;"> JQM is very slow </span> <a
href="#JQM_1" class="splitButtonClicked" data-rel="popup"> <span
style="float: right;"
class="ui-btn-up-b ui-btn-corner-all ui-icon ui-icon-arrow-r2"></span>
</a>
</h3>
<p>I sther any way so that page transition should happen just
like native applciation when using JQM ? Botton click also also
sometimes not responsive.</p>
</div>
</div>
<!-- content -->
<!-- footer -->
<div data-role="footer" data-theme="b" data-tap-toggle="false"
data-position="fixed">
<!--class="ui-bar ui-bar-b"-->
<a href="#" data-rel="back" data-role="button" data-icon="arrow-l"
data-iconpos="notext" class="ui-btn-left" data-theme="b">left</a>
<center>
<a href="#HomePage" data-role="button" data-icon="home"
data-iconpos="notext" data-theme="b">Home</a>
</center>
<a href="#" data-role="button" data-icon="arrow-r"
data-iconpos="notext" class="ui-btn-right" data-theme="b">Right</a>
</div>
<!-- /footer -->
</div>
</div>
</body>
</html>
项目
$.mobile.defaultPageTransition='none';
$.mobile.transitionFallbacks.slideout='none';
addEventListener('load',function()){
新建FastClick(document.body);
},假);
$(document).bind(“mobileinit”,function(){
$.mobile.buttonMarkup.hoverDelay=500
});
JQM非常慢
我选择了任何方式,以便页面转换正好发生
像使用JQM时的本机应用程序一样?波顿也点击了
有时没有反应
我没有在多个版本中使用jQuery Mobile,因此这可能不适用。但是您过去必须将数据role=“page”
元素作为主体
元素的子元素。也许这会有帮助。当我从代码中创建JSFIDLE时,它甚至没有初始化页面,当我删除#container
元素时,它开始初始化:。JSFIDLE工作得很好,因此您的糟糕性能还存在其他问题。你在测试什么?您是否使用诸如chrome的Timeline profiler之类的开发工具来找出问题所在?我正在Android 2.3中对此进行测试。我正在使用Phonegap将这些HTML转换为hative应用程序。我在另一个论坛上搜索并添加了一些改进,他们讨论了这些改进来解决性能问题,添加div容器就是其中之一。还有一个信息,我在一个html文件中有100个这样的页面。这是问题的根源吗?当我尝试使用2个页面时,当我有100个页面并尝试导航时,速度有点快,速度有点慢,导航大约需要2-3秒。同一文件中的100个页面太多。按类别划分页面(每个类别将获得自己的HTML文件),并在非ajax模式下加载单个类别。