关于vue $set在数组中使用问题

一般情况下,$set在对象中使用,例如

this.$set(person, 'age', 18);

然而,做项目时遇到了在数组中使用$set。那么数组中$set使用第二个参数就不能时属性了,而是index索引,例如

let arr = [a, b, c ];

假设arr为vue data里面的属性,我想动态在data里面加一个d,那么就要

this.$set(arr, 3, d);

这样就在arr最后面添加了d

项目代码如下

猜你喜欢

转载自blog.csdn.net/qq_40663497/article/details/86526458