1. At the first request
1.1 page
Used to limit the present data slice from 0, a is:
<div v-for="user in draw_user.slice(0,a)" :key="user.uid" class="user-item"> > //判断a的值是否小于数组的长度,小于就显示点击加载更多 > <div class="load-more mr-bottom" v-if="a<draw_user.length" @click='loadMore' >点击加载更多 > </div> > <div class="load-more mr-bottom" v-else >没有更多了</div>
1.2 data
A is a number defined in the data:
data() { return { a: 20 }; }
1.3 methods
LoadMore method defined in methods:
methods: { loadMore: funcution() { this.a += 20; } }
2. distribution request
2.1 page
<div class="load-more mr-bottom" v-if="page<page_count" @click='loadMore' >点击加载更多 </div> <div class="load-more mr-bottom" v-else >没有更多了</div>
2.2 data
data() { return { page: 1, page_count: '' }; },
2.3 methods
LoadMore method defined in methods:
loadMore: function() { this.page += 1; this.getDrawPrize({ current_page:this.page //请求页数 }) .then(ret => { console.log(ret.data.code_result) this.code_result = this.code_result.concat(ret.data.code_result); //将请求回来的数据和 上一次进行组合 }) .catch(err => { this.$toast.fail("系统开小差,请重试"); }); },