基于js实现数组相邻元素上移下移
实现效果: 即需要实现当前元素与相邻元素交换位置, 当上移时,则是当前元素与上一元素调换位置;当下移时,则是当前元素与下一元素调换位置。 实现代码: js: //点击上移 clickUp(index){ this.swapArray(this.tableData, index-1, index); }, //点击下移 clickDown(index){ this.swapArray(this.tableData, index, index+1); }, //数组元素互换位置 swapArray(arr, index1, index2) { arr[index1] = arr.spli
下载地址
用户评论