推薦一些好用的插件,可搭配react使用

react-sortable-hoc

作用:可以很簡便地對元素進行拖拽
用法:

import { SortableContainer, SortableElement } from "react-sortable-hoc";
import arrayMove from "array-move";

const SortableList = SortableContainer(({ children }) => {
  return children;
});

const SortableItem = SortableElement(({ children }) => {
  return children;
});
		  <SortableList
            axis="y"
            lockAxis="y"
            distance={1}
            onSortEnd={({ oldIndex, newIndex }) => {
              setList(arrayMove(list, oldIndex, newIndex));
            }}
          >
          	<ul>
          		<SortableItem key={index} index={index}>
          		...
          		</SortableItem>
          	</ul>
          </SortableList>

fileDialog

作用:封裝了圖片上傳的函數和回調
用法:

import fileDialog from "file-dialog";

fileDialog().then(file => {
    const data = new FormData();
    data.append("file", file[0]);
    data.append("imageName", "flower");
    // Post to server
  });

moment

作用:傳入一個date,返回一定格式的日期
用法:

import moment from "moment";

moment().format("YYYY-MM-DD HH:mm:ss")//返回 2020-03-24 17:43:20  這種格式
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章