【发布时间】:2023-01-09 21:42:22
【问题描述】:
我有两个这样的组件。
<ComponentA />
<ComponentB />
组件 A 可以水平滚动,但我想在组件 B 中显示它的滚动条。
<ComponentA >
some content over here which is wide enough to get horizontal scroll
</ComponentA>
<ComponentB>
some content
//scrollbar of ComponentA
more content
</ComponentB>
希望我把问题说清楚了:)
我想我可以使用 useRef 但不知道在这种情况下如何
【问题讨论】:
-
没看懂你的问题。。。组件A的滚动条是什么意思?
-
您只能在内容比父元素更宽/更高的元素上使用滚动条。因此,要么必须使 componentB 的内容比 B 宽,要么将 ComponentA 放在 ComponentB 中?
标签: javascript reactjs