繁体   English   中英

如何在Material-Datetime-Picker中设置自己的默认日期

[英]How To Set Own Default Date In Material-Datetime-Picker

在这里,我正在使用Material-datetime-picker 但是我只需要DOB(出生日期)的日期。 因此,在初始时间,默认日期应为1990年,我应该对material-datetime-picker.js应用哪些更改

的index.php

var picker = new MaterialDatetimePicker({})

  .on('submit', function(d) {
    var dt = d.format("DD/MM/YYYY");
    $("#dob").val(dt);
  });

$('#dob').click(function () {

picker.open();

});

替换material-datetime-picker.js中的代码

if (!this.value) {
    // TODO hack
    // set/setDate/setTime need refactoring to have single concerns
    // (set: set the value; setDate/setTime rename to renderDate/renderTime
    //  and deal with updating the view only).
    // For now this allows us to set the default time using the same quantize
    // rules as setting the date explicitly. Setting this.value meets setTime|Date's
    // expectation that we have a value, and `0` guarantees that we will detect
    this.value = moment(0);
    this.setDate(this.options.default);
    this.setTime(this.options.default);
  } else {
    this.setDate(this.value);
    this.setTime(this.value);
  }

if (!this.value) {
    // TODO hack
    // set/setDate/setTime need refactoring to have single concerns
    // (set: set the value; setDate/setTime rename to renderDate/renderTime
    //  and deal with updating the view only).
    // For now this allows us to set the default time using the same quantize
    // rules as setting the date explicitly. Setting this.value meets setTime|Date's
    // expectation that we have a value, and `0` guarantees that we will detect
    this.value = moment(0);
    this.setDate("12/12/1992");
    this.setTime(this.options.default);
  } else {
    this.setDate(this.value);
    this.setTime(this.value);
  }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM