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');
  }
},
相关推荐
Jonathan Star27 分钟前
JavaScript 中,原型链的**最顶端(终极原型)只有一个——`Object.prototype`
开发语言·javascript·原型模式
鹿衔`1 小时前
解决Flink on Yarn模式多Yarn Session会话提交
java·前端·flink
u***u6851 小时前
前端组件单元测试模拟,Jest mock函数
前端·单元测试
前端摸鱼匠2 小时前
Vue 3 的watchEffect函数:介绍watchEffect的基本用法和特点
前端·javascript·vue.js·前端框架·ecmascript
拉不动的猪2 小时前
基本数据类型Symbol的基本应用场景
前端·javascript·面试
天庭鸡腿哥2 小时前
谷歌出品,堪称手机版PS!
javascript·智能手机·eclipse·maven
_小九2 小时前
【开源】耗时数月、我开发了一款功能全面【30W行代码】的AI图床
前端·后端·开源
just小千2 小时前
HTML进阶——常用标签及其属性
前端·html
惜.己2 小时前
html笔记(一)
前端·笔记·html