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

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

相关推荐
mapbar_front35 分钟前
面试问题—上家公司的离职原因
前端·面试
昔人'1 小时前
css使用 :where() 来简化大型 CSS 选择器列表
前端·css
昔人'1 小时前
css `dorp-shadow`
前端·css
流***陌1 小时前
扭蛋机 Roll 福利房小程序前端功能设计:融合趣味互动与福利适配
前端·小程序
可触的未来,发芽的智生1 小时前
新奇特:黑猫警长的纳米世界,忆阻器与神经网络的智慧
javascript·人工智能·python·神经网络·架构
烛阴2 小时前
用 Python 揭秘 IP 地址背后的地理位置和信息
前端·python
前端开发爱好者2 小时前
尤雨溪官宣:"新玩具" 比 Prettier 快 45 倍!
前端·javascript·vue.js
why技术2 小时前
从18w到1600w播放量,我的一点思考。
java·前端·后端
欧阳呀2 小时前
Vue+element ui导入组件封装——超级优雅版
前端·javascript·vue.js·elementui
清风徐来QCQ2 小时前
css总结
前端