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