>》>》>》>》

js数组实现上移下移

up(index) {
            if(index === 0) {
              return
            }
            //在上一项插入该项
            this.list.splice(index - 1, 0, (this.list[index]))
            //删除后一项
            this.list.splice(index + 1, 1)

            this.save();
        },
        down(index) {
            if (index === (this.list.length-1)) {
              return
            }
            // 在下一项插入该项
            this.list.splice(index + 2, 0, (this.list[index]))
            // 删除前一项
            this.list.splice(index, 1)

            this.save();
        },

 

posted @ 2019-12-13 16:33  大、锤  阅读(4630)  评论(0编辑  收藏  举报