贴代码,望大神修改
var currentPage=1;
mui.init({
pullRefresh : {
container:"#refreshContainer",//上拉刷新容器标识,querySelector能定位的css选择器均可,比如:id、.class等
down : {
contentdown : "下拉可以刷新",//可选,在下拉可刷新状态时,下拉刷新控件上显示的标题内容
contentover : "释放立即刷新",//可选,在释放可刷新状态时,下拉刷新控件上显示的标题内容
contentrefresh : "正在刷新...",//可选,正在刷新状态时,下拉刷新控件上显示的标题内容
callback :pulldownRefresh //必选,刷新函数,根据具体业务来编写,比如通过ajax从服务器获取新数据;
},
up : {
contentrefresh : "正在加载...",//可选,正在加载状态时,上拉加载控件上显示的标题内容
contentnomore:'没有更多数据了',//可选,请求完毕若没有更多数据时显示的提醒内容;
callback :pullupRefresh //必选,刷新函数,根据具体业务来编写,比如通过ajax从服务器获取新数据;
}
}
});
mui.plusReady(function(){
var param=null;
loadData(param,currentPage,true);
});
function pulldownRefresh(){
var currentPage=1;
loadData(currentPage,true);
mui('#refreshContainer').pullRefresh().endPulldownToRefresh();
}
function pullupRefresh(){
currentPage++;
loadData(currentPage,true);
}
function loadData(param,currentPage,refresh){
mui.ajax(base_api_url+'/Interface/Activity/SelectActivity.aspx?PageIndex='+currentPage,{
dataType:'json',//服务器返回json格式数据
type:'get',//HTTP请求类型
success:function(data){
// var Pic=plus.storage.setItem("data[i].Pic");
//获得服务器响应
// mui('#refreshContainer').pullRefresh().endPullupToRefresh(true);
// mui('#refreshContainer').pullRefresh().endPulldownToRefresh(true);
var html='';
for(var i=0; i<data.length;i++){
var param=data[i].Id;
if(data[i].Pic!=''){
var picHtml='<img class="img-responsive" src="'+base_api_url+'/Image/'+data[i].Pic+'" alt="">';
}else{
var picHtml='<img class="img-responsive" src="image/active1.png" alt="">';
}
html+='<div class="con-list aligncenter" onclick="openwin('+param+')">'
+'<div class="col-xs-6">'+picHtml+'</div>'
+'<div class="col-xs-5">'
+'<div class="title">'+data[i].Title+'</div>'
+'<div class="time">'+data[i].StartTime+'</div>'
+'</div>'
+'<div class="col-xs-1 con-list-r"><em class="glyphicon glyphicon-triangle-right"></em></div>'
+'</div>'
}
if (refresh) {
//下拉刷新
$('#content').html(html);
mui('#refreshContainer').pullRefresh().endPulldownToRefresh();
} else {
// 上拉加载
currentPage++;
$('#content').append(html);
mui('#refreshContainer').pullRefresh().refresh(true);
}
}
});
}
niunan222
文档里的是 mui('#refreshContainer').pullRefresh().endPulldown(); 写错了,怪不得我这一直报错,天啊。。。。文档链接是:http://dev.dcloud.net.cn/mui/pulldown/#autopull
2018-02-17 14:43
6***@qq.com
为啥我依旧是一直在刷新重复数据
2018-07-27 19:51