mpvue 小程序如何開啓下拉刷新,上拉加載?

https://developers.weixin.qq.com/miniprogram/dev/api/pulldown.html#onpulldownrefresh 小程序APIhtml

微信小程序之下拉加載和上拉刷新
微信小程序下拉加載和上拉刷新兩種實現方法
方法一:onPullDownRefresh和onReachBottom方法實現小程序下拉加載和上拉刷新git

首先要在json文件裏設置window屬性github

屬性 類型 描述
enablePullDownRefresh Boolean 是否開啓下拉刷新,詳見頁面相關事件處理函數。

設置js裏onPullDownRefresh和onReachBottom方法json

屬性 類型           描述
onPullDownRefresh function 頁面相關事件處理函數——監聽用戶下拉動做
onReachBottom function 頁面上拉觸發底事件的處理函數
// 全局開啓下拉刷新在最外層的main.js下

 window: {
  enablePullDownRefresh: true,
}

// 局部開啓下拉刷新,就在文件下的main.js

export default {
  config: {
    "enablePullDownRefresh": true,
  }
}

// 下拉刷新方法,與methods方法同級

async onPullDownRefresh() {
  // to doing..
  // 中止下拉刷新
  wx.stopPullDownRefresh();
},

// 上拉加載,拉到底部觸發
onReachBottom() {
  // 到這底部在這裏須要作什麼事情
  this.loadMore();
},

個人GitHub博客,不少內容能夠看,喜歡的給星星哦 https://github.com/liangfengbo/frontend小程序

相關文章
相關標籤/搜索