当前位置: 首页 > news >正文

表格滚动分页查询

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();

  },


http://www.mrgr.cn/news/5682.html

相关文章:

  • 【Hot100】LeetCode—114. 二叉树展开为链表
  • 图像处理 -- 仿射变换之Affine Transformation
  • softmax多分类及多任务示例
  • 防范小程序隐私合规风险,筑牢用户信任防线
  • 海康VisionMaster使用学习笔记6-图像拼接
  • Ant-Design-Vue快速上手指南 + 排坑
  • 【C语言】关键字——const
  • 基于TCP服务的TLV编解码
  • OCR文字识别接口如何用Java进行调用
  • Android UI:PopupWindow:API
  • Studying-CodeTop | 3. 无重复字符的最长子串、206. 反转链表、146. LRU 缓存
  • uniapp 地图map画出地市轮廓
  • 2. springboot集成kafka入门使用教程
  • 已解决:java.lang.ClassNotFoundException: com.mongodb.test.test 异常的正确解决方法,亲测有效!!!
  • 进阶岛 - MindSearch(CPU版)部署到github codespace
  • 软件测试-测试分类
  • 独立ip为何高级又安全?
  • Scratch与AI:开启少儿编程的智能之旅
  • 编译原理(极速版)
  • 【简历】25届青岛某一本JAVA简历:中厂不要强调算法,面试官听不懂