示例:
wxml页面:
<picker name="picker_machine11" class="cybm_pic_1" range="{{categoryList}}" value="{{'categoryid'}}" range-key='name' bindchange="bindChangeCate"> <span class="picker"> <view class='flex-item'>{{showCategory}}</view> </span> </picker>
其中,range是数组类型:[{id:'',name:''}],value为选中后的值,range-key为显示字段,bindchange为绑定事件,绑定事件写法如下:
bindChangeCate: function (e) { let index = e.detail.value; let text = this.data.categoryList[index].name; if (text == '全部') { text = '职位类型' } this.setData({ cate_index: e.detail.value, showCategory: text + '⏷', categoryid: this.data.categoryList[index].id }); //查询事件写在此处 },
标签:picker,index,示例,微信,value,text,id From: https://www.cnblogs.com/jizhong/p/16709988.html