diff --git a/src/common.ts b/src/common.ts index 1adbe36e8a..4a18766dfe 100644 --- a/src/common.ts +++ b/src/common.ts @@ -115,7 +115,7 @@ export type InfinityScroll = TScroll; export interface ScrollToElementParams { /** 跳转元素下标 */ - index: number; + index?: number; /** 跳转元素距离顶部的距离 */ top?: number; /** 单个元素高度非固定场景下,即 isFixedRowHeight = false。延迟设置元素位置,一般用于依赖不同高度异步渲染等场景,单位:毫秒 */ @@ -124,5 +124,5 @@ export interface ScrollToElementParams { } export interface ComponentScrollToElementParams extends ScrollToElementParams { - key: string | number; + key?: string | number; } diff --git a/src/tree/_example/vscroll.jsx b/src/tree/_example/vscroll.jsx index 280a7564d7..9bfc2d8a06 100644 --- a/src/tree/_example/vscroll.jsx +++ b/src/tree/_example/vscroll.jsx @@ -13,7 +13,6 @@ export default () => { newOptions.push({ label: `第${i}段`, value: i, - key: i, children: [ { label: `第${i}段第1个子节点`, @@ -30,7 +29,7 @@ export default () => { }, []); const handleScroll = () => { - treeRef.current.scrollTo({ index: '10', behavior: 'smooth' }); + treeRef.current.scrollTo({ key: '10.1', behavior: 'smooth' }); }; const defaultChecked = ['1.2', '2.2'];