简体   繁体   English

单击反应时将 div 中的组件移动到另一个 div

[英]Move component in a div to another div when clicked in react

Let's say I have one component that only holds an image and two divs, one holding the compon.net, laid out as such:假设我有一个仅包含图像和两个 div 的组件,其中一个包含 compon.net,布局如下:

在此处输入图像描述

Upon being clicked, the component will move into the other div单击后,组件将移动到另一个 div 在此处输入图像描述

Then when the component is clicked again, it moves back to its original spot, like such:然后当再次点击该组件时,它会回到原来的位置,如下所示: 在此处输入图像描述

What would the logic be in order to accomplish this?为了实现这一点,逻辑是什么? Any help would be appreciated especially with code examples.任何帮助将不胜感激,尤其是代码示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM