vue 解决 数组和对象数据画面不更新

1.数据是数组类型的时候

原数据: this.testArr = [{c: 12}, {}];

操作: this.testArr[0]  = { a: 123 }/或者  this.testArr[0].c = 12222;操作完了以后不更新

执行操作 this.testArr = this.testArr.concat([ ]); 合并空数组,就能实现数据的更新

2,数据是对象

原数据 this.testArr = {a:{c: 12}, b:{}};

操作: this.testArr.a.c = 11111; 不更新

执行操作 this.testArr = Object.assign({},this.testArr,{}); 

猜你喜欢

转载自www.cnblogs.com/chenyi4/p/13402682.html