スクロールを下に自動ロード

2058 ワード

                  

{{bottomTipText}}


/*      */
.bottom-tip{
padding:.25rem 0;
text-align:center;
}

/*    */
bottomTip: false,
bottomTipText: '',
pages: {
//
noData: false,

page_size: 30,
  //    
page: 1,
//
last_page: 1
}
  
//
window.addEventListener('scroll', () => {
let scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
let clientHeight = document.documentElement.clientHeight || document.body.clientHeight;
let scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight;

if(scrollHeight > clientHeight && scrollTop + clientHeight >= scrollHeight) {
this.loadmore();
}
});
 
 
loadmore() {
if (this.pages.last_page > this.pages.page) {
this.pages.page++;
this.history();
}
},

xxx () {
this.bottomTipText = ' ...';
this.Api.xxx(this.pages, this.urlType).then( response => {
if (response['success']) {
this.bottomTip = true;
this.bottomTipText = ' ...';
this.pages.last_page = response['data']['last_page'];

if (response['data']['last_page'] <= this.pages.page) {
this.bottomTipText = ' ...';
if(!data.length) {
this.noData = true;
this.bottomTip = false;
} else {
this.noData = false;
}
}

}
})
},