使列表高度填满整个页面

时间:2019-10-20 03:37:57

标签: javascript react-virtualized

我目前正在尝试制作一个页面,其中一半在地图上,而另一半在列表上。我想让列表高度填满整个页面,但似乎找不到正确的方法。我使用react-virtualized列表代码库作为起点,在该代码中,您通过传入listHeight来指定高度尺寸。但我希望listHeight可以根据您的屏幕大小动态变化。

我尝试做flex:1,height:100%,但是似乎并没有影响代码。我需要以某种方式使高度值等于屏幕尺寸的大小。

<div style={{flex: 1}}>
    <AutoSizer>
        {({width}) => (
            <List
                ref="List"
                className={styles.List}
                height={listHeight}
                overscanRowCount={overscanRowCount}
                noRowsRenderer={this._noRowsRenderer}
                rowCount={rowCount}
                rowHeight={
                    useDynamicRowHeight ? this._getRowHeight : listRowHeight
                }
                rowRenderer={this._rowRenderer}
                scrollToIndex={scrollToIndex}
                width={width}
            />
        )}
    </AutoSizer>
</div>

1 个答案:

答案 0 :(得分:0)

style = {{height: "100vh"}}

这将占据窗口的整个垂直高度