微信小程序picker携带值问题

微信小程序中picker的携带至错误, 代码如下 从图片中可以看到value的值已经改变但是所携带的data-id
却没有改变这是为什么呢
或者说我想实现的是将showmain数组中的_id数值传到服务器有什么好方法吗


<picker mode="selector" disabled="{{down}}" bindchange="bindPickerChange" value="{{index}}" range="{{name}}" data-id="{{showmain[index]._id}}">
        <view class="name">
          <view>
            {{showmain[index].name}}
          view>

bindPickerChange: function (e) {
    console.log(this.data.showmain)
    console.log('picker发送选择改变,携带值为', e.detail.value)
    console.log('picker发送选择改变,携带值为', e.currentTarget.dataset.id )
    this.setData({
      index: e.detail.value
    })

img

数据流动是异步的,完全没必要再从data的形式获取了


bindPickerChange: function (e) {
    console.log(this.data.showmain)
    console.log('picker发送选择改变,携带值为', e.detail.value)
    console.log('picker发送选择改变,携带值为', e.currentTarget.dataset.id )
    const { showmain } = this.data
    //这个id就是你要传入服务器的id
    const id = showmain[e.detail.value]._id

    this.setData({
      index: e.detail.value
    })
this.setData({
  index:this.data.showmain[e.detail.value]._id
})