上移下移

// 上移
      moveUp(index) {
        console.log(index, 'moveUp');
        if (index > 0) {
          let update = this.list[index - 1]
          this.list.splice(index - 1, 1)
          this.list.splice(index, 0, update)
        } else {
          this.$Message.warning('已不可上移!')
        }
      },

      // 下移
      moveDown(index) {
        console.log(index, 'moveDown');

        if (index + 1 != this.list.length) {
          let downdate = this.list[index + 1]
          this.list.splice(index + 1, 1)
          this.list.splice(index, 0, downdate)
        } else {
          this.$Message.warning('已经是最后一条,不可下移!')
        }
      },

 

posted @ 2022-01-26 16:18  张小中  阅读(76)  评论(0)    收藏  举报