data attribute:
a: {},
b: [],
when getting data from the server in created, it needs to be filled in an and b, because the data needs Filter, so it cannot be assigned directly.
for(let key in response.data.list){
if(response.data.list[key].type == 2){
this.a[key] = response.data.list[key]
}
}
when you change the value of a, the view does not refresh.
read the document and said that it is because there is no property in a that is added by key, to $set.
however, the operation on b has two results.
do this:
for(let key in response.data.list){
if(response.data.list[key].type == 1){
this.b.push(response.data.list[key])
}
}
modify the value of b and the view will be refreshed.
if so:
let index = 0;
for(let key in response.data.list){
if(response.data.list[key].type == 1){
this.b[index] = response.data.list[key]
index PP
}
}
modify the value of b and the view will not be refreshed.
Why don"t you need $set? for push