数组两个参数之间交换位置 使用splice方法实现
2020-03-23 本文已影响0人
小北酱丶
//上移
topStudent(index) {
this.studentData.splice(
index,
1,
...this.studentData.splice(index - 1, 1, this.studentData[index])
);
},
//下移
bottomStudent(index) {
this.studentData.splice(
index + 1,
1,
...this.studentData.splice(index, 1, this.studentData[index + 1])
);
},