小程序picker方法

183 阅读1分钟

GIF 2021-9-26 星期日 14-52-29.gif

   <view class="row" wx:if="{{cilentId}}">
        <view class="label">意向课程</view>
        <picker mode="selector" value="{{kcname}}" range="{{sortList}}" range-key="title"
            bindchange="changeSort">
            <view class="enter">
                <input type="text" value="{{kcname}}" placeholder="请选择意向课程" disabled />
                <view class="arrow imgCenter">
                    <image src="../../utils/static/arrow.png" mode="widthFix" />
                </view>
            </view>
        </picker>
    </view>
    

sortList为后台返回的数据

image.png

  changeSort(e){
    let inx=e.detail.value
    let list=this.data.sortList
    this.setData({
      kcname:list[inx].title,
      kcid:list[inx].id
    })
  },