发布于 2023-03-21, 更新于 2023-04-09
创建可拖拽、调整大小的元素。rnd 的意思是:resizable and draggable。
https://github.com/bokuweb/react-rnd
npm i -S react-rnd
适合 html 编辑器场景。
bounds: parent 使其不得超过特定的画布区域(父级区域)。import { Rnd } from "react-rnd";
const style = {
display: "flex",
alignItems: "center",
justifyContent: "center",
border: "solid 1px #ddd",
background: "#f0f0f0"
};
<Rnd
style={style}
default={{
x: 0,
y: 0,
width: 320,
height: 200
}}
>
Rnd
</Rnd>