微信小程序日历插件

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,
    })
  }

 

 

微信小程序日历插件

上一篇:【Spring Boot 快速入门】二十、Spring Boot 基于AOP注解实现日志记录功能


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