Skip to content

[t-table组件] tableRef.value.scrollToElement 无法滚动到第一行 #6385

@DoctorWei

Description

@DoctorWei

tdesign-vue-next 版本

1.18.0

重现链接

官方文档例子可复现:https://stackblitz.com/run?file=package.json,src%2Fdemo.vue

重现步骤

const scrollToElement: ButtonProps['onClick'] = () => {
  tableRef.value.scrollToElement({
    // 方式一:跳转元素下标(第 256 个元素位置)
    // index: 255,
    // 方式二:使用行唯一标识跳转到指定行(id = 255)
    key: 255,
    // 滚动元素距离顶部的距离(如表头高度)
    top: 47,
    // 高度动态变化场景下,即 isFixedRowHeight = false。延迟设置元素位置,一般用于依赖不同高度异步渲染等场景,单位:毫秒。(固定高度不需要这个)
    time: 60,
  });
};

指定key为255 即id为255,top=47,实际滚动到256
指定key为255,top=0,实际滚动到257

当我设置key=1,top=47时,实际滚动到第2行
当我设置key=1,top=0时,实际滚动到第3行

当我设置key=0,控制台报错 TDesign Table Error: scrollToElement: one of index or key must exist.

所以当我想通过指定方式滚回第一行时,无法滚动到第一行

期望结果

No response

实际结果

No response

框架版本

No response

浏览器版本

No response

系统版本

No response

Node版本

No response

补充说明

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐞 bugSomething isn't working

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions