vue强制更新$forceUpdate()
添加this.$forceUpdate();进行强制渲染,效果实现。搜索资料得出结果:因为数据层次太多,render函数没有自动更新,需手动强制刷新。
调用强制更新方法this.$forceUpdate()会更新视图和数据,触发updated生命周期。
我是在使用多层for循环嵌套时出现的页面没有及时刷新改变后的值的问题( 使用this.$forceUpdate() )
使用方法:
在方法执行完毕后添加this.$forceUpdate()
当然了,也可以使用vue中的方法 this. s e t ( o b j e c t , i n d e x , n e w ) t h i s . set(object, index, new) this. set(object,index,new)this.set()方法是vue自带的可对数组和对象进行赋值,并触发监听的方法。
第一个参数为你要改变的数组或对象
第二个参数为下标,或者元素名称
第三个参数为新值
例:
this.$set(
this.accumulateList[index],
'sum_money',
res.result,
);