阅读背景:

关于上移下移,一行代码完成数据交换

来源:互联网 
      onMoveUp (index) {
          if (index !== 0) {
          this.swapArray(this.dataList, index, index - 1)
        } else {
          this.$message({message: '已经处于置顶,无法上移', type: 'warning'})
        }
      },
      onMoveDown (index) {
        let len = this.dataList.length
        if (index + 1 !== len) {
          this.swapArray(this.dataList, index, index + 1)
        } else {
          this.$message({message: '已经处于置底,无法下移', type: 'warning'})
        }
      },
      swapArray (arr, indexOne, indexTwo) {
        arr[indexOne] = arr.splice(indexTwo, 1, arr[indexOne])[0]
        return arr
      }      onMoveUp (index) {
          if (in



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: