首页 > 解决方案 > 使列表的高度填满整个页面

问题描述

我目前正在尝试制作一个页面,其中一半是地图,另一半是列表。我想让列表高度填满整个页面,但我似乎找不到正确的方法。我使用 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>

标签: javascriptreact-virtualized

解决方案


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

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


推荐阅读