小程序国家、时间、日期选择器(转)


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