<h1 v-show="person.name">{{person.name}}</h1>
data(){
return{
person:{
name:'张三',
age:15,
hobby:['学习','吃饭']
}
}
},
methods:{
sbhj(){
this.$set(this.person,'sex','女')//增减1
Vue.set(this.person,'sex','女')//增减2
this.$delete(this.person,'name')//删除1
Vue.delete(this.person,'name','女')//删除2
this.$set(this.person.hobby,0,'逛街')//修改1
this.person.hobby.splice(0,1,''逛街)//修改2
}
}
vue2响应式,添加删除修改
最新推荐文章于 2024-04-09 13:12:49 发布