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();
        },

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM