// 交换数组元素
var swapItems = function(arr, index1, index2) {
arr[index1] = arr.splice(index2, 1, arr[index1])[0];return arr;
};
// 上移
const newArray = swapItems(arr, $index, $index - 1);
// 下移
const newArray = swapItems(arr, $index, $index + 1);