picker多級選擇器的使用————小程序


picker多級選擇器的使用————小程序

picker是選擇器來着,既然選擇了,就希望可以獲取選擇的數據。

index.html

<view>picker獲取數據</view>
<view class="cu-form-group margin-top">
  <picker bindchange="bindPickerChange" value="{{index}}" range="{{array}}">//改變bindchange后,執行bindPickerChange。
    <view class="picker">當前選擇:{{array[index]}}</view>
  </picker>
</view>
<view class="picker">當前選擇:{{array[index]}}</view>//任何數據能讀出來的才叫好數據。
<view class="picker">當前選擇:{{userChange}}</view>

index.js

  bindPickerChange: function (e) {
    console.log('picker發送選擇改變,攜帶下標為', e.detail.value)//獲取選擇的值的下標value
    console.log('picker發送選擇改變,攜帶值為', this.data.array[e.detail.value])//獲取選擇的值
    this.setData({
      index: e.detail.value,//值要定義過才能用
      userChange:this.data.array[e.detail.value]//值要定義過才能用
    })
  },


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM