react 实现鼠标拖拽移动 我们可以引入一个组件是 react-rnd
即通常的引用
npm i react-rnd -S
安装后 引用就可以了
import {Rnd} from 'react-rnd'
用的时候只需要在想要被拖动的内容外面套上<Rnd></Rnd>标签就可以了
如 (尴尬了 这个markdown不识别 箭头函数)
<Rnd
size={{ width: item.width, height: item.height }}
position={{ x: item.x, y: item.y }}
onDragStop={(e, d) => this.moveItem(e,d,item)}
onResizeStop = {(e,direction,ref,delta,position) => this.changeItem(e,direction,ref,delta,position,item)}
key={item.id}
>
<Input type="primary"
style={{
width: item.width ||'',
height: item.height || ''
}}
key={item.id} ref={'ref'+ item.id}
onDoubleClick = { e =>this.handleCheckedTxt(e, item)}
placeholder = "请输入"></Input>
</Rnd>