更新对象并持久化

时间:2018-08-02 22:01:51

标签: javascript arrays object vuejs2

我有这个对象:

enter image description here

我想更新每个学生的对象,每个学生都有一个唯一的索引(来自数据库的ID),因此我可以稍后将该对象发送到服务器,这就是我尝试过的方式:

studentID =参数(整数)
notes =参数(对象)

每次我更改形式的输入时都会调用该函数

for (let i = 0; i < this.studentNotes[studentID].desempenos.length; i++) {
    if (this.studentNotes[studentID].desempenos[i].desempeno === desempeno) {
        this.studentNotes[studentID].desempenos[i].nota = notes.nota;
    }
}

问题是这样的: 我输入了索引190的值并保存了它,但是当我想保存其他索引的值时,比如说191,它将覆盖190中的值。

我不知道为什么。

谢谢。

0 个答案:

没有答案