欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 教育 > 高考 > 表格滚动分页查询

表格滚动分页查询

2025/11/8 16:08:57 来源:https://blog.csdn.net/song_song0927/article/details/141394365  浏览:    关键词:表格滚动分页查询
1.给表格添加id,height="100%"是固定表头

<el-table

            id="attr-table-box"

            height="100%"

            :row-style="{ height: '66px' }"

            style="width: 100%; height: 100%; "

          >

2.使用计算属性获取总页数

 computed: {

    //  表格总页数,控制滚动查询 attrTotal是数据总数;

    attrTotalPage() {

      return Math.ceil(this.attrTotal / this.queryParamsAttr.pageSize);

    },

  },

3.主要方法
// 属性表格绑定滚动事件,滚动分页查询queryByScroll() {const _this = this;const tableScrollDom =document.getElementById("attr-table-box").childNodes[2];tableScrollDom.addEventListener("scroll", function () {const scrollTop = tableScrollDom.scrollTop;const clientHeight = tableScrollDom.clientHeight;const scrollHeight = tableScrollDom.scrollHeight;if (scrollTop + clientHeight == scrollHeight) {// 滚动到底部if (_this.attrTotalPage > _this.queryParamsAttr.pageNum) {// 如果当前还没到最后一页,滚动到底部以后继续查询_this.queryParamsAttr.pageNum++;// 请求数据_this.getAttrData();}} else {}});},
4.在mounted里调用

 mounted() {

     this.queryByScroll();

  },

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com