Detailed explanation of Vue.js's mobile component library mint-ui to achieve infinite scrolling loading more

小云云
Release: 2017-12-23 15:52:25
Original
2790 people have browsed it

Through many crawling pits, I discovered that these methods of listening to scrolling to load more components have something in common. Because these methods of loading more components are bound to elements that need to load more content, they enter the page. Then it is triggered once directly, and after the scroll event is monitored, it continues to load more, so there is no need to write a function for the first load list for infinite scroll loading. This article will share with you an article on the Vue.js mobile component library mint-ui to achieve infinite scrolling and loading more methods. It has a good reference value and I hope it will be helpful to everyone. Let’s follow the editor to take a look, I hope it can help everyone.

The code is as follows:

html:

//父组件 

//LifeLists组件:

LifeListItem组件:

{{item.title}}

{{item.monetaryUnit}}{{item.price}}

{{item.title}}

发布于{{formatTime(item.createAt)}} {{item.countryName}} {{item.cityName}}

{{item.detail}}

{{item.like}}

{{item.commentCount}}

Copy after login

vue.js

data:

page:0, size:10, loadingTextBtn:false, loadingText:"努力加载中", loadingComplete:false, refreshComplete:false, city:"", country:""
Copy after login

methods:

loadMore() { this.loading = true; this.loadingTextBtn=true; if(parseInt(this.page)==0){ this.$store.dispatch('loadMoreLifeList',{city:"纽约",country:"美国",category:"",page:this.page,size:this.size}); this.page++; }else if(parseInt(this.page)>0&&parseInt(this.page) { // this.$store.dispatch('loadMoreLifeList',{city:this.city,country:this.country,category:"",page:this.page,size:this.size}) this.$store.dispatch('loadMoreLifeList',{city:"纽约",country:"美国",category:"",page:this.page,size:this.size}); this.page++; }, 1000); }else{ this.loadingText="已全部加载完成"; this.loadingComplete=true; this.loading = false; } },
Copy after login

The important thing here is to judge that when the current page is 0, that is, the first page, there is no need for a setTimeout timer and a direct request to load. When more is loaded, a timer can be added.

I found a lot of mint-ui loadmore components on the Internet to implement pull-up to load more. Since the pull-up triggers the corresponding load more event, the data should not be automatically loaded when entering the page, so here You can add a function to get the first page of data.

Related recommendations:

Detailed explanation of native JS to control multiple scroll bars to follow the scrolling synchronously

How to implement it in vue Scroll to load more functions

Detailed explanation of CSS3 to achieve infinite loop seamless scrolling

The above is the detailed content of Detailed explanation of Vue.js's mobile component library mint-ui to achieve infinite scrolling loading more. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!