wxml
<picker range='{{objectArray}}' value='{{index}}' bindchange="Change" range-key="name">
<view class='picker'>{{objectArray[index].name}}</view>
</picker>
wxjs
Page({
data:{
objectArray: [{ name: 'key1', id: 20 }, { name: 'key2', id: 24 }, { name: 'key3', id: 25}],
index: 0,//索引
},
Change: function (e) {
this.setData({
index: e.detail.value
})
var indes = e.detail.value;
var dataid = this.data.objectArray[indes]['id'];
console.log(dataid);
},
})