How does WeChat Mini Programs assign values dynamically?


this.setData({
    "bottomTip[this.data.nav.currentIndex].state": 2
})

this.data.nav.currentIndex is indeterminate

is there a way to assign values like this?


var state= "bottomTip["+this.data.nav.currentIndex+"].state";
this.setData({
   [state]: 2
})


data: {
   bottomTip:[]
  }

changeData: function(){
    bottomTip[this.data.nav.currentIndex].state = 2
    this.setData({
        bottomTip: bottomTip
    })
}
Menu