微信小程序日历插件

1/   wxml代码

<view class="timePick">
    <picker mode="date" fields="month" value="{{timestamp}}" start="1999-01-01" end="2999-12-12" bindchange="datePickerBindchange">
      {{dateValue}}
    </picker>
  </view>

2/  js

 data: {
    searchDate:"",
    timestamp:""
  },
onLoad: function(options) {
    //日历默认值设置
    this.timestamp=new Date().getTime()
  },
datePickerBindchange:function(e){
    let date = e.detail.value+-01 00:00:00.0;
    date = date.substring(0,19);
    // date = date.replace(/-/g,‘/‘);
    let timestamp = new Date(date).getTime();  //插件再次打开时日期
    let picktime=e.detail.value
    let timeString=picktime.replace(/-/g,)+;
    // this.setData({
    //   dateValue:e.detail.value
    // })
    this.setData({
      searchDate:date,
      // searchDate:picktime,
      dateValue:timeString,   //1019年12月
      timestamp:picktime,
    })
  }

 

 

微信小程序日历插件

上一篇:微信小程序日历插件


下一篇:深度 | 带领国产数据库走向世界,POLARDB底层逻辑是什么?