【发布时间】:2017-12-03 19:38:56
【问题描述】:
你说得对,我没有正确传递道具。现在我把它设置成这样:
容器.jsx
<div className='container' ref={(ref) => {this.foo = ref;}}>
this.renderContainer()
</div>
<Section scrollContainer={this.foo}/>
Section.jsx(只是传递道具)
<Panel scrollContainer={this.props.scrollContainer}/>
Section.propTypes = { scrollContainer: PropTypes.object.isRequired }
Panel.jsx(传递道具)
<RenderedTable scrollContainer={this.props.scrollContainer} />
RenderedTable.jsx
return (
<div className='padding-top-20 font-smoothing'>
<WindowScroller scrollElement={this.props.scrollContainer}>
{({ height, isScrolling, scrollTop, onChildScroll }) => (
<AutoSizer disableHeight>
{({ width }) => (
<Table
不幸的是,windowScroller 仍然没有调整大小。我也没有收到任何警告或错误。您是否使用 css 技巧来调整滚动条的大小?我在示例中看到了 https://bvaughn.github.io/react-virtualized/#/components/WindowScroller 在将 scrollElement 从 window 更改为 scrollingBody 时更改 flex 和 overflow 属性。
我知道您很忙,非常感谢您的帮助!
【问题讨论】: