小程序-picker之key-value形式
Posted phoebemoon
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了小程序-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
},