Page({
/**
* 页面的初始数据
*/
data: {
age:0,
sgtz:0,
jgz:0,
number:0,
index:0,
objectarray: [
{
sex: '女',
num:0.85
},
{
sex: '男',
num:1
}
]
},
bindPickerChange: function (e) {
console.log(e)//('picker发送选择改变,携带值为', e.currentTarget.dataset.operation)
this.setData({
index: e.detail.value,
number : e.currentTarget.dataset.operation,
})
},
wxml-------
<view class=“section”>
<view class=“section__title”>普通选择器</view>
<picker bindchange=“bindPickerChange” range=’{{objectarray}}’ range-key=‘sex’ data-operation="{{objectarray[index].num}}" value=’{{objectarray[index].num}}’>
<view class=“picker” ban="">
当前选择:{{objectarray[index].sex}}
</view>
<view >{{number}}</view>
</picker>
</view>