elment Table多级表头固定列后,合计行错位显示问题解决

复制代码
<el-table-column :label="tabsDataFilters1.orgName" width="370" :fixed="tableFixed">
  <el-table-column type="index" label="序号" width="50" align="center" :fixed="tableFixed"></el-table-column>
  <el-table-column prop="name" label="姓名" width="200" align="left" :fixed="tableFixed"></el-table-column>
  <el-table-column prop="age" :formatter="formatAmount" label="小计" width="120" align="center" :fixed="tableFixed"></el-table-column>
</el-table-column>

mounted进行监听,监听方法如下:

observeClassChanges() {
  debugger
  this.$nextTick(() => {
    const bodyWrapper = this.$refs.table1.$el.querySelector('.el-table__body-wrapper');
    if (!bodyWrapper) return;

    // 创建 MutationObserver 监听 class 变化
    this.observer = new MutationObserver((mutationsList) => {
      for (const mutation of mutationsList) {
        if (mutation.attributeName === 'class') {
          this.removeScrollingClasses(bodyWrapper);
        }
      }
    });

    // 监听 `class` 变化
    this.observer.observe(bodyWrapper, {
      attributes: true,
      attributeFilter: ['class'],
    });

    // 初始移除 class,防止渲染时已有
    this.removeScrollingClasses(bodyWrapper);
  });
},
// 滚动中间行样式移除
removeScrollingClasses(bodyWrapper) {
  if (bodyWrapper.classList.contains('is-scrolling-middle')) {
    bodyWrapper.classList.remove('is-scrolling-middle');
  }
  if (bodyWrapper.classList.contains('is-scrolling-left')) {
    bodyWrapper.classList.remove('is-scrolling-left');
  }
},
相关推荐
李剑一23 分钟前
别再瞎写电子围栏了!这2种动态效果,科技感直接拉满,源码直接抄走!
前端·vue.js·cesium
木易士心41 分钟前
从 MVP 到千万级并发:AI 在前后端开发中的差异化落地指南
前端·后端
葡萄城技术团队43 分钟前
字体与打印:前端开发最常见的三个“为什么”
前端
王夏奇1 小时前
python中的深浅拷贝和上下文管理器
java·服务器·前端
siger1 小时前
徒手开荒-我用纯Nodejs+pnpm+monorepo改造了一个多vue2的iframe"微前端"项目
前端·node.js·前端工程化
lichenyang4531 小时前
海克斯大乱斗攻略网站 —— 从零开发到云服务器部署全记录
前端
你的代码僚机1 小时前
《别再被 SSO 骗了!前端单点登录原理+避坑指南》
前端
不懂代码的切图仔1 小时前
移动端h5实现横屏在线签名
前端·微信小程序
少卿1 小时前
OpenClaw 的 summarize 技能——开发者的智能摘要利器
前端·后端·程序员
仰望.1 小时前
vue vxe-table 数据分组与排序的实现方式
vue.js·vxe-table