微信小程式上拉載入,下拉重新整理

2021-10-07 20:52:37 字數 865 閱讀 3387

首先在對應的json檔案中開啟

"enablepulldownrefresh"

:true

首先介紹上拉載入的方法

1.data中定義

data:

,

2.請求資料方法

getcompanylist()

, data:

, success:

(res)

=>

if(res.data.items ==0)

);}else);

}let listdata =

this

.data.page ==1?

:this

.data.items;

this

.setdata()

if(res.data.pages.pagecount <=

this

.data.page));

}else)}

;}})

},

3.上拉方法

onreachbottom:

function()

,

下面介紹下拉重新整理

onpulldownrefresh:

function()

)this

.getcompanylist()

//方法呼叫

wx.stoppulldownrefresh()

//停止當前頁面下拉重新整理

},

微信小程式 上拉重新整理和下拉載入

上拉重新整理和下拉加載有兩種方式可以實現 1.使用scroll view元件進行操作,使用自帶的scrolltoupper和scrolltolower事件可以實現。適合頁面區域性的上拉下拉。附上文件 2.使用page頁面事件處理函式 onpulldownrefresh 下拉重新整理 和 onreac...

微信小程式上拉載入更多和下拉重新整理

獲取商品列表 async getgoodslist 關閉下拉重新整理 wx.stoppulldownrefresh 生命週期函式 監聽頁面載入 onload function options 頁面上拉觸底事件的處理函式 onreachbottom function fail complete els...

小程式上拉載入下拉重新整理

筆者這邊上拉載入使用的函式是 onreachbottom,沒有使用scroll view data 生命週期函式 監聽頁面載入 onload function options 商品 goods function that,urls function error 頁面上拉觸底事件的處理函式 onrea...