zoukankan      html  css  js  c++  java
  • uni-app上划加载分页效果

    html部分:

    // 列表组件
    <dataList ref="course" :courseList="courseList" />
    // 分页加载更多组件(该组件要去插件市场安装)
    <uni-load-more v-if="courseList.length > 5" :contentText="contentText" :status="status" />

    js部分:

    <script>
        // 引入列表组件(自己手写)
        import dataList from './components/dataList'
        export default {
            components: {
                dataList
            },
            data() {
                status: 'more',
                contentText: {
                    contentdown: "加载更多",
                contentrefresh: "正在加载...",
                contentnomore: "已经到底了哟QAQ~"
                },
                courseList: [],
                total: 0,
            pagination: {
            current: 1,
            size: 5
            },
            },
            onShow() {
            this.getData()
        },
        onReachBottom() {
            const { total } = this;
            const { current, size } = this.pagination;
            if (total > (current * size)) {
            this.status = 'loading';
            this.pagination.current++;
            this.getData(true);
            } else {
            this.status = 'noMore';
            }
        },
        methods: {
                 async getData(more) {
            let res = await uni.service.home.getCourseList(this.pagination)
            if (res.code === 200) {
                        if (more) {
                            this.courseList = this.courseList.concat(res.data.records);
                        } else {
                            this.courseList = res.data.records
                        }
                            this.total = res.data.total;
                this.status = 'more';
                    }
                }
        }
        }
    </script>                                
  • 相关阅读:
    445port入侵具体解释
    重构摘要12_大型重构
    Matlab画图-非常具体,非常全面
    期望DP
    自己实现一个SQL解析引擎
    信息熵(Entropy)究竟是用来衡量什么的?
    速算123,公布
    OCP-1Z0-051-题目解析-第28题
    选择排序
    Android入门第八篇之GridView(九宫图)
  • 原文地址:https://www.cnblogs.com/bella99/p/15093005.html
Copyright © 2011-2022 走看看