在vue中,如果你在初始data里定義一個對象,然后例如ajax后去賦值這個對象涕烧,直接用=的方法区赵,是不生效的,那如何去實(shí)現(xiàn)呢 vue官方解決方法
對象單個的設(shè)置
this.$set(this.paramd,"phone",res.body.msg.phone)
this.$set(this.paramd,"age",res.body.msg.age)
this.$set(this.paramd,"name",res.body.msg.name)
但是如果你對象里參數(shù)很多齐板,可以這樣
this.paramd = Object.assign({},this.paramd,{
id:res.body.msg.id,
name:res.body.msg.name,
picked:res.body.msg.sex,
age:res.body.msg.age,
phone:res.body.msg.phone
})