【发布时间】:2021-03-12 23:25:57
【问题描述】:
我在拼接数组时遇到问题。我正在尝试拼接它以修改该数组中元素的位置,但它返回时出现错误。
if (e.target !== dragNode.current) {
setUrls((oldList) => {
let newList = [...oldList];
newList.splice(
params.idx,
0,
newList[currentItem].splice(currentItem.idx, 1)[0]
);
dragItem.current = params;
return newList;
});
}
旧列表在哪里:
OLD LIST
(2) ["x", "x"]
0: "x"
1: "x"
length: 2
__proto__: Array(0)
还有新名单:
NEW LIST
(2) ["x", "x"]
0: "x"
1: "x"
length: 2
__proto__: Array(0)
【问题讨论】:
标签: javascript node.js reactjs