小程序國家、時間、日期選擇器(轉)


js代碼:

//index.js
//獲取應用實例

var app = getApp()

Page({

data: {

date: '2016-11-08',

time: '12:00',

array: ['中國', '巴西', '日本', '美國'],

index: 0,

},


onLoad: function () {



},
// 點擊時間組件確定事件

bindTimeChange: function (e) {

this.setData({

time: e.detail.value

})

},
// 點擊日期組件確定事件

bindDateChange: function (e) {

this.setData({

date: e.detail.value

})

},
// 點擊國家組件確定事件

bindPickerChange: function (e) {

this.setData({

index: e.detail.value

})

}
})

 

 


wxml代碼:

<view class="section" style="background:#787878;margin:20rpx;padding:20rpx">

<picker bindchange="bindPickerChange" value="{{index}}" range="{{array}}">

<view class="picker">
國家:{{array[index]}}
</view>

</picker>

</view>

<view class="section" style="background:#787878;margin:20rpx;padding:20rpx">

<picker mode="time" value="{{time}}" start="09:01" end="21:01" bindchange="bindTimeChange">

<view class="picker">
時間: {{time}}
</view>

</picker>

</view>

<view class="section" style="background:#787878;margin:20rpx;padding:20rpx">

<picker mode="date" value="{{date}}" start="2015-09-01" end="2017-09-01" bindchange="bindDateChange">

<view class="picker">
日期: {{date}}
</view>

</picker>

</view>


免責聲明!

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



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