Yas*_*sir 5 css list reactjs react-virtualized
我正在使用 React-Virtualized 创建一个延迟加载无限列表。
https://github.com/bvaughn/react-virtualized/blob/master/docs/InfiniteLoader.md
但是,我无法在渲染的 div 之间创建间隙,因为它们是绝对定位的并且顶部是动态计算的。
我尝试过以下方法,但没有运气。关于如何在每个元素之间添加这种间隙有什么想法吗?谢谢!
<AutoSizer disableHeight>
{({width}) => (
<List
onRowsRendered={onRowsRendered}
ref={registerChild}
rowCount={rowCount}
rowRenderer={rowRenderer}
width={width - 30}
rowHeight={175}
height={this.state.height - 64}
style={{
paddingTop: 15,
boxSizing: 'content-box',
}}
containerStyle={{
position: 'relative',
overflow: 'visible',
}}
/>
)}
</AutoSizer>
Run Code Online (Sandbox Code Playgroud)
我最终通过在 CellMeasurer 内添加一个 div 作为父容器来提供填充来解决填充问题。
div 是绝对定位的容器,而 Card 是有填充的并显示框阴影。
<CellMeasurer
cache={this.cache}
columnIndex={0}
key={key}
rowIndex={index}
parent={parent}
>
{({ measure }) => (
<div
className={s.listItem}
style={style}
onLoad={measure}
key={index}>
<Card>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5632 次 |
| 最近记录: |