Dokumentasi pembangunan applet WeChat
/ 微信小程序表單組件選擇器 picker
微信小程序表單組件選擇器 picker
微信小程序picker
滾動選擇器,現(xiàn)支持三種選擇器,通過mode來區(qū)分,分別是普通選擇器,時間選擇器,日期選擇器,默認(rèn)是普通選擇器
普通選擇器:mode=selector
時間選擇器:mode=time
日期選擇器:mode=date
示例代碼:
<view class="section"> <view class="section__title">地區(qū)選擇器</view> <picker bindchange="bindPickerChange" value="{{index}}" range="{{array}}"> <view class="picker"> 當(dāng)前選擇:{{array[index]}} </view> </picker> </view> <view class="section"> <view class="section__title">時間選擇器</view> <picker mode="time" value="{{time}}" start="09:01" end="21:01" bindchange="bindTimeChange"> <view class="picker"> 當(dāng)前選擇: {{time}} </view> </picker> </view> <view class="section"> <view class="section__title">日期選擇器</view> <picker mode="date" value="{{date}}" start="2015-09-01" end="2017-09-01" bindchange="bindDateChange"> <view class="picker"> 當(dāng)前選擇: {{date}} </view> </picker> </view>
Page({ data: { array:["美國","中國","巴西","日本"], index:0, date:"2016-09-01", time:"12:01" }, bindPickerChange: function(e) { console.log('picker發(fā)送選擇改變,攜帶值為', e.detail.value) this.setData({ index: e.detail.value }) }, bindDateChange:function(e){ this.setData({ date:e.detail.value }) }, bindTimeChange:function(e){ this.setData({ time:e.detail.time }) } })