小程序-picker之key-value形式

##小程序的picker的取值 都是通过index 去取

 

<picker @change="statusChange" value="{{statusIdx}}" range="{{statusSel}}">
  <view class="picker">
  状态 <text class="iconfont icon-down"></text>
  </view>
</picker>
 
data = {  
  statusSel: ['全部', ''请假, '休假', ],
  statusIdx: 0,
  orderStatus: '全部',
  
}
statusChange () { 
  this.statusIdx = e.detail.value
  this.orderStatus = this.statusSel[this.statusIdx]
}
 
但是现在需要 key value 的类型 range-key 便起作用
<picker @change="useChange" value="{{useIdx}}" range="{{useList}}" range-key="{{'key'}}">
  <view class="weui-select weui-select_in-select-after">{{useList[useIdx].key}}</view>
</picker>
 
data =  {
  statusSel: [{"key":"alle"',value:'全部'},{"key":",},]
}
 
useChange(e) {
  this.useIdx = e.detail.value
  this.financingUse = this.useList[this.useIdx].key
},
 
posted @ 2018-09-27 17:22  phoebemoon  阅读(4525)  评论(0编辑  收藏  举报