vue3+ts table表格滚动条滚动指定位置

scrollBarPosition() {
   nextTick(() => {
          setTimeout(() => {
            let dom =
              document.querySelector('.el-drawer__body') ||
              (document.body as Element)
            const leftGap =
              dom.clientWidth > 1200
                ? dom.scrollWidth / 1.4
                : (dom.scrollWidth + dom.clientWidth) / 2
            tableRef.value?.scrollTo({
              left: leftGap,
              behavior: 'instant'
            })
          }, 100)
  })
}

 

posted on 2022-06-08 16:33  lyuyi  阅读(1371)  评论(0编辑  收藏  举报

导航