在vue中,对于复杂数组可能无法更新数据的方法
强制更新:this.
f
o
r
c
e
U
p
d
a
t
e
(
)
对
于
复
杂
数
组
更
新
数
据
时
,
用
t
h
i
s
.
forceUpdate() 对于复杂数组更新数据时,用 this.
forceUpdate()对于复杂数组更新数据时,用this.set()方法能实现响应式
goup(e){ //重要
//this.soga[e].duihua = !this.soga[e].duihua
if(this.soga[e].duihua){
this.$set(this.soga, e, {...this.soga[e],duihua:false})
}else{
this.$set(this.soga, e, {...this.soga[e],duihua:true})
}
console.log('sd',this.soga)
//this.$forceUpdate() //强制更新,这个很重要啊
},