1、如何给小程序data数据中的对象中的某个属性赋值
2、比如userCrad对象中的属性是输入框input获取的用离开焦点事件bindblur="bindblur"拿到input的值value
data: {
userCrad:{
photoUrl:'',
name:'',
phone:'',
companyName:'',
job:'',
email:'',
wxName:'',
companyAddress:''
}
},
// input更新userCrad值 这样就可以赋值了
bindblur(e){
let type = e.currentTarget.dataset.type //为userCrad对象的属性名photoUrl/name/phone等
let val = e.detail.value
let name = `userCrad.${type}` //重点在这里 userCrad.name最为key
this.setData({
[name]: val
})
},