【问题标题】:How to correctly plugin in a Reactjs Scroll bar module如何在 Reactjs 滚动条模块中正确插入
【发布时间】:2015-09-24 17:15:27
【问题描述】:

我采用简单的Facebook flux-chat 示例并为“MessagesSection”组件插入更好的滚动条

滚动条的插件是here

我安装了模块,在“MessagesSection”中需要它,并将新组件包装在消息列表中,如下所示:

render: function() {
    var postListItems = this.state.posts.map(getPostListItem);
    return (
      <div className="post-section">
        <h3 className="post-thread-heading">{this.state.thread.name}</h3>

        <ul className="post-list" ref="postList">
                <ScrollbarWrapper>
                  <div>             
                   {postListItems}
                  </div>
                </ScrollbarWrapper>
        </ul>

        <PostComposer threadID={this.state.thread.id}/>
      </div>
    );
  }

**注意:我也尝试将它包裹在无序列表周围。

但滚动条保持不变(仍然是以前的基本 chrome 滚动条)。

滚动条没有改变,我做错了什么?

【问题讨论】:

    标签: javascript facebook plugins reactjs scrollbar


    【解决方案1】:

    将此 CSS 复制粘贴到 index.html 中:https://github.com/ojame/react-scrollbars/blob/master/examples/views/home/examples/custom-scrollbar.css

    并像这样使用包装器上的类:&lt;ScrollbarWrapper className="ScrollbarContent--custom"&gt;

    【讨论】:

    • 快到了!旧的 chrome 滚动条会一直显示,直到我将鼠标悬停。组件窗口大小也缩小了。
    • 重要的不是到达那里,而是变得更好!祝你好运;)
    • 适用于以后阅读本文的任何人。这是最后的部分 - 更改提到的 css 文件以匹配组件的高度并添加它,以便滚动条仅在悬停时显示。 .ScrollbarContent--自定义 { 宽度:100%;高度:400px;溢出:隐藏;背景:RGB(253、253、253); } .ScrollbarContent--custom:hover { 溢出:自动; }
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-04
    • 1970-01-01
    • 1970-01-01
    • 2020-04-08
    • 1970-01-01
    • 2021-06-29
    相关资源
    最近更新 更多