js代码
<script type="text/javascript" src="js/zepto.min.js"></script> <script type="text/javascript" src="js/PullToRefresh.min.js"></script> <script type="text/javascript"> var n=0,flag=true; function appendTestData(){ return "<li><h5>"+Math.floor(Math.random()*1000)+"</h5><p>现在开始报时:"+new Date()+"</p></li>" } function addhtml(type){ console.log("第"+n+"次加载成功") $(".tip").html("第"+n+"次") $("#app ul")[type](appendTestData()+appendTestData()+appendTestData()+appendTestData()) } var refreshBox=new PullToRefresh({ container:"#app", pull:{ callback:function(){ setTimeout(function(){ n=0 addhtml("html") refreshBox.endPullRefresh(true) },1000) } }, up:{ callback:function(){ setTimeout(function(){ if(n<5){ n++ addhtml("append") refreshBox.endUpLoading(true) }else{ //没有数据 refreshBox.endUpLoading(false) } },1000) } } }) </script>