博客列表 >Uniapp上拉加载数据

Uniapp上拉加载数据

鱼的熊掌
鱼的熊掌原创
2023年01月31日 16:06:42765浏览
<template>    <view class="tcVisit_page">            <view v-if="historyList.length">                <view class="evaluation_box lh26" v-for="(item,index) in historyList" :key="index">                    <view>                        <text><b>姓名:</b> {{ item.name }} </text>                     </view>                    <view>                        <text><b>电话:</b> {{ item.phone }} </text>                     </view>                </view>            </view>            <view v-else class="noVote">                <view class="img" style="text-align:center;">                    <img src="/static/img_jidu/parent/empty.png" alt="">                    <text class="">暂无数据</text>                </view>            </view>        </view>    </view></template>
<script>    import {        getList    } from '@/api/visit.js'    export default {        data() {            return {                isOver:false,                campus:[],                historyList: [],                pageInfo: {                    page: "1",                    limit: 10,                },            }        },        onLoad() {            getList(this.pageInfo).then(res => {                this.historyList = res            })        },        onShow(){            document.title="记录";        },        methods: {            // 下拉到底部后加载新数据            onReachBottom() {                //判断下一页是否存在数据,不存在将显示暂无数据等提示语                if (!this.isOver) {                    this.pageInfo.page++; //页数加一                    this.findData(); //回调接口                }            },            findData() {                getList(this.pageInfo).then(res => {                    if (res.length < this.pageInfo.limit) this.isOver = true;                    for (let i = 0; i < res.length; i++) {                        this.historyList.push(res[i]);                    }                })            }        }    }</script>
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议