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 這種格式