【问题标题】:React Virtualized windowscroller scrollElement not working反应虚拟化的windowscroller scrollElement不工作
【发布时间】: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 属性。

我知道您很忙,非常感谢您的帮助!

【问题讨论】:

    标签: react-virtualized


    【解决方案1】:

    在您的示例中,您已将滚动引用分配给 this.tabsContainer,但您尝试以 this.props.tabContainer 的身份访问它。要么这是您的错误,要么示例不完整,需要更多上下文。 :) 你能提供一个 Plnkr 吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-03
      • 2018-01-23
      • 2018-07-27
      • 1970-01-01
      • 2018-02-10
      • 2018-08-16
      • 2022-01-10
      • 2017-08-28
      相关资源
      最近更新 更多