使用layui中得时间选择器组件时,若存在开始时间和结束时间时:
var start_a = laydate.render({ elem: '#realTimeBegin', type: 'datetime', trigger: 'click', //采用click弹出 theme: '#3278F0', done: function (value, date, endDate) { console.log(date); end.config.min = { date: date.date, hours: date.hours, minutes: date.minutes, month: date.month - 1, seconds: date.seconds, year: date.year}; //开始日选好后,重置结束日的最小日期 end.config.value = { date: date.date, hours: date.hours, minutes: date.minutes, month: date.month - 1, seconds: date.seconds, year: date.year }; //将结束日的初始值设定为开始日 } });
//结束时间 var end = laydate.render({ elem: '#realTimeEnd', type: 'datetime', trigger: 'click', //采用click弹出 theme: '#3278F0', done: function (value, date, endDate) { start_a.config.max = { date: date.date, hours: date.hours, minutes: date.minutes, month: date.month - 1, seconds: date.seconds, year: date.year }; //结束日选好后,重置开始日的最大日期 } });
参考:https://blog.csdn.net/yjie970715/article/details/89537576