使用ReactJ在两个Div之间移动两个Div
enter image description hereenter image description hereI need some help in the react js project:
I have two div in react component, I want to switch between them using two buttons.
When you press the first button, the first div appears and the second disappears and the opposite is also true.
If possible, please explain it with a simple example, and thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它必须非常简单,您可以通过控制您的按钮的状态变量获得它。
此状态变量
选项
将保持1
或2
,如果选择了1
,则它将显示第一个内容部分,否则将显示第二个内容部分。和
onclick
这些选项上的将更改state
变量。这是一个代码。 沙盒上的代码
简单的CSS
It must be very simple and you can get it by a state variable that will control your buttons.
This state variable
option
will hold1
or2
and if1
is selected then it will show the first content part, otherwise 2nd content part will be shown.And
onClick
on these options will change thestate
variable.Here is a code. Code on sandbox
Simple CSS