小程式分頁,滾動條滾到底部時往列表裡新增資料

2021-08-19 23:16:47 字數 815 閱讀 2272

0}}" class="loading"> }

wxss:

.loading, 'post').then(function (res) {

if (res.errno === 0) {

let goods = ;

if (!paged) {

goods = res.data;

else{

//當滾動到頁面底部時,往列表裡新增資料,其它情況(關鍵字查詢,頁籤切換等)只顯示一頁資料

goods = that.data.goodslist.concat(res.data);//concat:複製整個陣列到前面的陣列

that.setdata({

loadingtip: '',

nomoredata: false,

goodslist: goods,

if (res.data.length < that.data.size) {

that.setdata({

nomoredata: true,

js:* 頁面相關事件處理函式--監聽使用者下拉動作

onpulldownrefresh: function () {

this.data.page = 1

this.getgoodslist();

* 頁面上拉觸底事件的處理函式

onreachbottom: function () {

if (!this.data.nomoredata) {

this.data.page = this.data.page + 1;

this.getgoodslist(true);

JS如何判斷滾動條是否滾到底部

判斷滾動條到底部,需要用到dom的三個屬性值,即scrolltop clientheight scrollheight。scrolltop為滾動條在y軸上的滾動距離。clientheight為內容可視區域的高度。scrollheight為內容可視區域的高度加上溢位 滾動 的距離。從這個三個屬性的介紹...

JS如何判斷滾動條是否滾到底部

判斷滾動條到底部,需要用到dom的三個屬性值,即scrolltop clientheight scrollheight。clientheight 這個元素的高度,占用整個空間的高度,所以,如果乙個div有滾動條,那個這個高度則是不包括滾動條沒顯示出來的下面部分的內容。而只是單純的div的高度。scr...

Vue 元件內滾動條 滾到到底部

因為在vue中,某個元件內 使用scrolltop賦值 滾動條沒有變化 使用scrollto 也不行 window.scorllto 或者dom.scrollto 所以可以考慮使用投機取巧的辦法 利用在指定位置新增乙個div 然後通過div.scrollintoview 滾動到這個div 跳轉到po...