0.1.1 • Published 10 months ago

react-drag-images-component v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

react-drag-images-component

介绍

图片拖拽排序的组件

安装

npm i -D react-drag-images-component

参数说明

参数说明类型默认值
data图片渲染数据列表,{url: '', id: ''},...Array[]
width图片宽度Number200
height图片高度Number200
isOpen是否展示展开收起按钮Booleantrue
isDrag是否允许拖拽Booleantrue
col展示的列数Number5
row默认展示的行数Number1
isBorder最外层边框Booleantrue
borderColor最外层边框颜色String-
onChage拖拽 change 事件Function-

通过数据渲染

import { DragImages } from "react-drag-images-component";

const App = () => {
  const handleChange = (data) => {
    console.log(data);
  };

  return <DragImages data={[]} onChange={handleChange} />;
};

自定义数据渲染

请确保 key 与 id 保持一致且不重复

import { DragImages } from "react-drag-images-component";

const App = () => {
  const [data, setData] = useState([]);

  const handleChange = (data) => {
    console.log(data);
  };
  return (
    <DragImges data={data} onChange={handleChange}>
      {data.map((item) => (
        <div key={item.id} className="aaa">
          <img
            src={item.url}
            style={{
              width: "100%",
              height: "100%",
              objectFit: "cover",
              cursor: "pointer",
            }}
            draggable="false"
          />
        </div>
      ))}
    </DragImges>
  );
};
0.1.1

10 months ago

0.1.0

10 months ago

0.0.13

10 months ago

0.0.12

10 months ago

0.0.11

10 months ago

0.0.10

10 months ago

0.0.9

10 months ago

0.0.8

10 months ago

0.0.7

10 months ago

0.0.6

10 months ago