微信小程序用setData给数组对象赋值

假如现在要给数组marker中的对象属性赋值
data: {
  marker: [
    {
     latitude: ' ' ,
     longitude: ' '
    }
  ]
},
 
在方法中的写法为
 
fetchJobInfor ( ) {
  let  lat = 'marker[0].latitude'
  let  lon = 'marker[0].longitude'
  this.setData({
    [lat]:  ' 赋值1 ',
    [lon]: ' 赋值2 '
  })
}

猜你喜欢

转载自www.cnblogs.com/xiaopenzai/p/9493232.html
今日推荐