Code前端首页关于Code前端联系我们

微信小程序开发:列表页加载下一页及下拉刷新实现方法

terry 2年前 (2023-09-23) 阅读数 74 #移动小程序

微信小程序开发列表页加载下一页及下拉刷新实现方法,微信列表页常用功能有下拉刷新、滑动上传更多,如何实现它?

我们直接上代码吧:

列表页面js

global.p = 1

var url = getApp().globalData.API_URL +'/api/index.php?m=jk&c newslist ' ;

var GetList = function (that) {

//console.log(global.p)

that.setData({

hidden: false,

});

wx .request ({

url: url,

data: {

页面大小: 10,

pageNo: global.p

},

函数(清除)

函数toDate (number) {

var n = number * 1000;

var date = new Date(n);

var Y = date.getFullYear() + '/';

var M = (date .getMonth( ) + 1 var D = date.getDate( ) return (Y + M + D)

}

var l = that.data.list

for (var i = 0; i res.data[i].pubdate = toDate(res.data[i].pubdate),

l.push(res.data[ i] )

}

//console.log(l)

that.setData({

list : l

});

global.p++;

global.p++;

// console.log(global.p)

wx.stoppulldownrefresh();

that.setData({

hidden:true

});

}

});♶}

}

}}}}} : {

list: [],

},

onLoad: function (options) {

//页面初始化选项就是页面跳转给出的参数

var that = this

GetList(that)

wx.request({

url: getApp().globalData.API_URL +'/api/index.php?m=jk&c=nlmlist',

success:function(res ){

that.setData({

nlmlist:res.data

})

}

})

},

},

l (

) {sh:Down

console.log("下拉");

global.p = 1;

this.setData({

list: [],

} );

var that = this

GetList(that)

},

onReachBottom: function () {

//上拉

console.log("上拉")

var that ❝ this = this GetList(this)

}

})

版权声明

本文仅代表作者观点,不代表Code前端网立场。
本文系作者Code前端网发表,如需转载,请注明页面地址。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门