1 回答

TA贡献1793条经验 获得超6个赞
我认为您只是插入dragableId,您可以使用该函数找到整个对象并插入整个对象newRowOrder.splice(destination.index, 0, **draggableId**);Array.find
onDragEnd = (result) => {
const { destination, source, draggableId, type } = result;
if (!destination) {
return;
}
if (
destination.draggableId === source.droppableId &&
destination.index === source.index
) {
return;
}
if (type === "row") {
const draggableRow = this.state.currentRows.find(row => row.id === draggableId);
const newRowOrder = Array.from(this.state.currentRows);
newRowOrder.splice(source.index, 1);
newRowOrder.splice(destination.index, 0, draggableRow);
const newState = {
...this.state,
currentRows: newRowOrder,
};
this.setState(newState);
}
}
添加回答
举报