下拉刷新
第一:
mui.init({ pullRefresh: { container: ‘#pullrefresh‘, up: { contentrefresh: ‘正在加载...‘, callback: pullupRefresh } } });
第二:
var i = 0; var count = 0; var number = 1; function pullupRefresh(){ setTimeout(function(){ $(function(){ var json = {}; json.competitionID = CompetitionID; json.fightTypeID = fightTypeID; json.action = ‘getFightType‘; $.post(‘http://192.168.3.12:11000/api/Competition‘, json, function(e){ var obj = eval("(" + e + ")"); var data = obj.data[0].v_teamfight; if(number > data.length){ number = data.length; } var counts = parseInt(data.length/2)+1; //定义上拉次数 mui(‘#pullrefresh‘).pullRefresh().endPullupToRefresh((++count >counts)); //判定是否拖动 for(i; i < number; i++){ var str = ‘‘; str += "<span>" + data[i].TeamAName + "</span>"; //A队名称 str += "</div><div>vs</div><div>"; str += "<img src=‘../../img/hwq/gold.png‘/>"; //B队logo路径(暂无) str += "<span>" + data[i].TeamBName + "</span>"; //B队名称 $("#content").append(str); } number+=1; }); }); },100); }
第三:
if(mui.os.plus){ mui.plusReady(function(){ setTimeout(function(){ mui(‘#pullrefresh‘).pullRefresh().pullupLoading(); },10); }); } else { mui.ready(function() { mui(‘#pullrefresh‘).pullRefresh().pullupLoading(); }); }
时间: 2024-10-05 04:44:58