ElementUI 表格横向滚动条时滚动到指定位置

ElementUI 表格横向滚动条时滚动到指定位置

复制代码
  getColumnOffset(columnProp) {
      this.$nextTick(() => {
        const table = this.$refs.tableRef.$refs.multipleTable;
        const columns = table.columns;
        const column = columns.find((col) => col.property === columnProp);
        if (column) {
          // const cell = table.$el.querySelector(`th[data-property=${columnProp}]`);
          const cell = table.$el.querySelector(`.${column.id}`);

          if (cell) {
            const rect = cell.getBoundingClientRect();
            const offset = rect.left - table.$el.getBoundingClientRect().left;
            console.log(`${columnProp}列距离左侧的位置是: ${offset}px`);
            this.$refs.tableRef.$refs.multipleTable.bodyWrapper.scrollLeft = `${offset}`; //Number(this.$refs.tableRef.$refs.multipleTable.bodyWidth.replace('px',''));
          }
        }
      });
    },

this.getColumnOffset("operName");

会将滚动条滚动到设置的列,方便编辑;

相关推荐
前端snow14 分钟前
ai agent ---output汇总
前端
4311媒体网15 分钟前
帝国CMS网站自定义搭建技巧
服务器·开发语言·前端
JunjunZ18 分钟前
Vue 3 文件预览的通用设计与实现
前端·vue.js
CappuccinoRose18 分钟前
ES6+ 核心语法糖
前端·es6·解构·可选链·空值合并
两只羊ovo26 分钟前
Promise.all 并发请求实战:从串行 await 到双段并行
前端
七牛开发者1 小时前
解读 Cordis:dsh 一切皆插件背后的运行时设计
前端·javascript·后端
雷工笔记1 小时前
KingFusion驾驶舱-产能信息模块开发实战
javascript
BigTopOne1 小时前
ArLiveLite 学习计划
前端
慧都小项1 小时前
夜间Web回归跑到一半停了?TestComplete 15.83提升批量测试稳定性
前端·测试工具·数据挖掘·回归·汽车·web
两只羊ovo1 小时前
Agent ≠ 聊天机器人:从一问一答到 ReAct 循环,到底差在哪?
前端