wxml
<picker class='li-input' bindchange="pickChange" value="{{sexindex}}" data-value="sexindex" range="{{sexarray}}">
<text> {{sexarray[sexindex]?sexarray[sexindex]:'請選擇'}}</text>
</picker>
JS data部分
sexarray: ['男','女'],
sexindex:'',
JS 點(diǎn)擊事件
pickChange: function (e) {//普通選擇器
var that = this
let index = e.currentTarget.dataset.value
that.setData({//點(diǎn)擊后更新數(shù)據(jù)
[index]: e.detail.value
});
// console.log('picker發(fā)送選擇改變畸肆,攜帶下標(biāo)為' + e.detail.value)
},