Sillong
Sillong
  • 发布:2019-11-22 10:42
  • 更新:2019-11-22 10:43
  • 阅读:1085

改变data中数组对象里面元素顺序,页面不重新渲染,不支持es6解构赋值

分类:uni-app
let index = parseInt(e.currentTarget.dataset.index);  
let indexUp = parseInt(index-1);  
let editMessage = this.editMessage;  
[this.editMessage[index], this.editMessage[indexUp]] = [this.editMessage[indexUp], this.editMessage[index]];  
console.log(this.editMessage) // 数组内部元素已经发生改变
2019-11-22 10:42 负责人:无 分享
已邀请:
Sillong

Sillong (作者)

目前解决方式:

                let index = parseInt(e.currentTarget.dataset.index);  
                let indexUp = parseInt(index-1);  
                let editMessage = this.editMessage;  
                [editMessage[index], editMessage[indexUp]] = [editMessage[indexUp], editMessage[index]];  
                this.editMessage = [];  
                for(let item of editMessage) {  
                    this.editMessage.push(item)  
                }  
                this.editMessage = editMessage;  
                console.log(this.editMessage)

该问题目前已经被锁定, 无法添加新回复