在公司项目开发时,有一个需求是实现可以分页的订单列表,由于是移动端项目,所以最好的解决方法是做下拉加载更多。
- <van-list
- v-model="loading"
- :finished="finished"
- finished-text="没有更多了"
- @load="onLoad"
- >
- <van-cell
- v-for="(item,index) in orderList"
- :key="index" class="orderList"
- @click="goDetail(item.orderNo)"
- >
- <div class="order"> div>
- van-cell>
- van-list>
- onLoad(){
- this.loading = true;
- //分页
- this.pageNum++
- //请求数据
- this.getList()
- },
- getList(){
- let params = {
- size: 10,
- current: this.pageNum,
- }
- this.$http.post('xxxxxxxx',params).then(res => {
- if (res.code == 0){
- this.orderList = this.orderList.concat(res.data.rows)
- this.loading = false
-
- if (res.data.rows.length < 10){
- this.finished = true
- }else{
- this.finished = false
- }
- }else{
- this.$toast.fail(res.msg)
- }
- })
- }