微信小程序数组赋值

 
        
  
data: {
    lists:[
      {
       "reward":"",
      },
    ],
  },
bindRewrdInput:function(e){
    var val = e.detail.value;  //获取输入框的数据
    **let index = e.currentTarget.dataset.index**  // 获取数据的索引
    **let  reward = 'lists[' + index +'].reward'**  // 获取lists[index].reward
    var lists = that.data.lists;
    **that.setData({
      [reward]:val
     })**
     console.log(lists)
  },

你可能感兴趣的:(前端,小程序)