微信小程序--多种类型日期选择器(年月、月日...)

这里写自定义目录标题
微信小程序--多种类型日期选择器(年月、月日...)
时间选择器(年月日)
时间选择器(年月)
时间选择器(年)
时间选择器(月日)
时间选择器(月)
时间选择器(日)
微信小程序–多种类型日期选择器(年月、月日…)
在业务开发的过程中,有许多对picker选择器的使用场景,根据开发需要列出了几种常见的类型,可供大家共同参考、学习

时间选择器(年月日)
效果图:

wxml:

<picker mode="date" header-text="选择时间"  value="{
  {date}}" bindchange="bindDateChange">
  <view class="font30">
    <text class="color3">填报时间:</text>
    <text class="color6">{
  {date}}</text>
    <text class="timeIcon">▼</text>
  </view>
</picker>

js

data:{
  date:'2021-01-01',
},
bindDateChange: function(e) {
  console.log('picker发送选择改变,携带值为', e.detail.value)
  this.setData({
    date: e.detail.value
  })
},

wxss

.font30{
  font-size: 30rpx;
}

.color3{
  color: #333;
}

.color6{
  color: #666;
}

.timeIcon{
  color:#666;
  font-size:18rpx;
  margin-left: 5rpx;
}

时间选择器(年月)

效果图:

wxml:

<picker mode="date" header-text="选择时间" fields="month" value="{
  {date}}" bindchange="bindDateChange">
  <view class="font30">
    <text class="color3">填报时间:</text>
    <text class="color6">{
  {date}}</text>
    <text class="timeIcon">▼</text>
  </view>
</picker>

js

data:{
  date:'2021-01',
},
bindDateChange: function(e) {
  console.log('picker发送选择改变,携带值为', e.detail.value)
  this.setData({
    date: e.detail.value
  })
},

wxss

.font30{
  font-size: 30rpx;
}

.color3{
  color: #333;
}

.color6{
  color: #666;
}

.timeIcon{
  color:#666;
  font-size:18rpx;
  margin-left: 5rpx;
}

时间选择器(年)

wxml:

<picker mode="date" header-text="选择时间" fields="year" value="{
  {date}}" bindchange="bindDateChange">
  <view class="font30">
    <text class="color3">填报时间:</text>
    <text class="color6">{
  {date}}</text>
    <text class="timeIcon">▼</text>
  </view>
</picker>

js

data:{
  date:'2021',
},
bindDateChange: function(e) {
  console.log('picker发送选择改变,携带值为', e.detail.value)
  this.setData({
    date: e.detail.value
  })
},

wxss

.font30{
  font
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值