调用方法:Vue.set( target, key, value )
target:要更改的数据源(可以是对象或者数组)
key:要更改的具体数据
value :重新赋的值
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <div> <p v-for="(item,index)in list" :key="item.id" @click="btnClick(index,item.id)"> {{item.message}} </p> </div> <script src=""></script> <script> var vm2=new Vue({ el:"#app", data:{ list:[ {message:"星星",id:"1"}, {message:"太阳",id:"2"}, {message:"月亮",id:"3"} ] }, methods:{ btnClick(index,id){ this.$set(this.list,index,{message:"小猫",id:id}); } } }); </script> </body> </html>