当前位置:   article > 正文

微信小程序分页效果实现_小程序分页查询demo

小程序分页查询demo

index.js

  1. // pages/bianmin/bianmin.js
  2. var p = 0
  3. var GetList = function (that) {
  4. wx.request({
  5. url: url,
  6. method: "POST",
  7. data: {
  8. page: p
  9. },
  10. header: {
  11. 'content-type': 'application/x-www-form-urlencoded'
  12. },
  13. success: function (res) {
  14. var l = that.data.list
  15. for (var i = 0; i < res.data.length; i++) {
  16. l.push(res.data[i])
  17. }
  18. that.setData({
  19. list: l
  20. });
  21. p++;
  22. }
  23. });
  24. };
  25. Page({
  26. /**
  27. * 页面的初始数据
  28. */
  29. data: {
  30. page: 0,
  31. list: [],
  32. },
  33. /**
  34. * 生命周期函数--监听页面加载
  35. */
  36. onLoad: function (options) {
  37. var that = this
  38. p = 0;
  39. GetList(that);
  40. },
  41. /**
  42. * 生命周期函数--监听页面初次渲染完成
  43. */
  44. onReady: function () {
  45. },
  46. /**
  47. * 生命周期函数--监听页面显示
  48. */
  49. onShow: function () {
  50. },
  51. /**
  52. * 生命周期函数--监听页面隐藏
  53. */
  54. onHide: function () {
  55. },
  56. /**
  57. * 生命周期函数--监听页面卸载
  58. */
  59. onUnload: function () {
  60. },
  61. /**
  62. * 页面相关事件处理函数--监听用户下拉动作
  63. */
  64. onPullDownRefresh: function () {
  65. p = 0;
  66. this.setData({
  67. list: [],
  68. });
  69. var that = this
  70. GetList(that)
  71. },
  72. /**
  73. * 页面上拉触底事件的处理函数
  74. */
  75. onReachBottom: function () {
  76. console.log("上拉")
  77. var that = this
  78. GetList(that)
  79. console.log(p)
  80. },
  81. /**
  82. * 用户点击右上角分享
  83. */
  84. onShareAppMessage: function () {
  85. }
  86. })


声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/一键难忘520/article/detail/753559
推荐阅读
相关标签
  

闽ICP备14008679号