1

我正在使用react-virtualized,并尝试使用该scrollToIndex功能,但在使用它时我得到一个空列表。(如果我滚动,那么我的列表会再次显示)。

这是我的代码:

        <WindowScroller>
        {({ height, isScrolling, scrollTop }) => (
            <AutoSizer disableHeight>
                {({ width }) => (
                    <List
                        autoHeight
                        height={height}
                        rowCount={lines.length}
                        rowRenderer={({ index, key, style }) => rowRenderer({ index, isScrolling, key, style, lines, onDelete, toggle })}
                        rowHeight={145}
                        scrollTop={scrollTop}
                        scrollToIndex={100}
                        width={width}
                    />
                    )}
            </AutoSizer>
            )}
    </WindowScroller>

如果我删除 scrollToIndex={100},一切正常。

是否scrollToIndex适用于WindowScroller?因为我只找到了它的例子List

4

1 回答 1

6

scrollToIndex 是否适用于 WindowScroller?因为我只用 List 找到了它的例子

不幸的是,当使用 WindowScroller 时,此功能当前不起作用,因为 WS 控制滚动位置(而不是 List 本身)。在使用 WindowScroller 的同时使用 scrollToIndex 会给 List 冲突信息和事情中断。

这是一个之前出现过一两次的问题,所以也许我最终会尝试支持它。

编辑

从9.8.0版本开始,WindowScroller 支持 scrollToIndex 属性。

于 2016-12-11T15:46:52.510 回答