zoukankan      html  css  js  c++  java
  • 滚动调到底部自动加载

    浏览器滚动到底部 会自动加载更多数据
    <section class="bottom-tip" v-if="bottomTip">
    {{bottomTipText}}
    </section>
    <div class="no-data" v-if="noData">
    暂无数据
    </div>
    /*底部加载更多*/
    .bottom-tip{
    padding:.25rem 0;
    text-align:center;
    }

    /*变量属性*/
    bottomTip: false,
    bottomTipText: '',
    pages: {
    // 每页数
    noData: false,

    page_size: 30,
      // 当前页
    page: 1,
    // 最后一页
    last_page: 1
    }
      
    // 监听滚动条 加载更多
    window.addEventListener('scroll', () => {
    let scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
    let clientHeight = document.documentElement.clientHeight || document.body.clientHeight;
    let scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight;

    if(scrollHeight > clientHeight && scrollTop + clientHeight >= scrollHeight) {
    this.loadmore();
    }
    });
    
    
    loadmore() {
    if (this.pages.last_page > this.pages.page) {
    this.pages.page++;
    this.history();
    }
    },

    xxx () {
    this.bottomTipText = '加载中...';
    this.Api.xxx(this.pages, this.urlType).then( response => {
    if (response['success']) {
    this.bottomTip = true;
    this.bottomTipText = '滑动加载更多...';
    this.pages.last_page = response['data']['last_page'];

    if (response['data']['last_page'] <= this.pages.page) {
    this.bottomTipText = '暂无更多数据...';
    if(!data.length) {
    this.noData = true;
    this.bottomTip = false;
    } else {
    this.noData = false;
    }
    }

    }
    })
    },
  • 相关阅读:
    c++笔试题3
    C++笔试题
    C++编程指南续(10-11)
    C++详解(8-9)
    C++编程指南(6-7)
    C++编程指南续(4-5)
    C++编程指南续
    C++的编程指南
    HPSocket介绍与使用
    WinForm中TreeView控件实现鼠标拖动节点(可实现同级节点位置互换,或拖到目标子节点)
  • 原文地址:https://www.cnblogs.com/zhaofeis/p/11492503.html
Copyright © 2011-2022 走看看