数据类型:
heros: [
{ id: 1, name: ‘盖伦’, hp: 318},
{ id: 2, name: ‘提莫’, hp: 320},
{ id: 3, name: ‘安妮’, hp: 419},
{ id: 4, name: ‘死歌’, hp: 325},
{ id: 5, name: ‘米波’, hp: 422},
],
watch方法:
watch:{
heros:{
handler(newVal, oldVal){
newVal.forEach((val,index)=>{
if(val.hp==340){
val.hp=0;
}
})
},
deep:true
}
},
来源:CSDN
作者:我要当学霸111
链接:https://blog.csdn.net/woyaodangxueba11/article/details/88967453