小程序修改data中数组或者对象里面的某一项值
data:{ list:{ data1:{}, passengers:[ name:'' ] } }
设置某一项的值
var that=this, num="list.data1"; that.setData({ [num]:that.data.list.data1.push(XXX) })
动态设置
inputVal: function (e) { var name = e.currentTarget.dataset.name; var index = e.currentTarget.dataset.index; var value = 'passengers['+index+'].'+name+''; this.setData({ [value]: e.detail.value }) }