我试图在我的Web应用程序上使用WindowScroller + AutoSizer + List的组合。只有AutoSizer + List才能实现虚拟化。但是,当我把它放在WindowScroller中时,行列表不再正确显示。
这是应用WindowScroller时的外观。 list result
我已经在这里和文档中搜索了可用的解决方案。发现类似的问题在这里发布,但提供的答案已经应用于我的代码。现在,我无法弄清楚究竟是什么阻碍了行的显示。
return (
<React.Fragment>
<WindowScroller>
{({height, isScrolling, onChildScroll, scrollTop}) => (
<AutoSizer disableHeight>
{({width}) => (
<List
autoHeight
height={height}
isScrolling={isScrolling}
onScroll={onChildScroll}
rowCount={rows.length}
rowHeight={30}
rowRenderer={({ index, style }) => <div style={style}>Row {index}</div>}
scrollTop={scrollTop}
width={width}
>
</List>
)}
</AutoSizer>
)}
</WindowScroller>
</React.Fragment>
);
看来这是一个实施问题。我用于WindowScroller引用的容器元素的溢出样式未正确设置。