1. upTr(index,arr) { // 上移
    2. if (index === 0) {
    3. return
    4. }
    5. this.swapItems(arr, index, index - 1);
    6. },
    7. downTr(index,arr) { // 下移
    8. if (index === arr.length - 1) {
    9. return
    10. }
    11. this.swapItems(arr, index, index + 1);
    12. },
    13. swapItems(arr, index1, index2,direction) {
    14. if(direction=='up'){//置顶
    15. arr.unshift(arr[index1]);
    16. arr.splice(index1+1,1);
    17. return arr;
    18. }
    19. if(direction=='down'){//置底
    20. arr.push(arr[index1]);
    21. arr.splice(index1,1);
    22. return arr;
    23. }
    24. arr[index1] = arr.splice(index2, 1, arr[index1])[0];
    25. return arr;
    26. },
    27. //使用
    28. this.swapItems(layers2DArr,layers2DIndex, 0,'up') //置顶
    29. this.swapItems(layers2DArr,layers2DIndex, layers2DArr.length-1,'down')