layui.laydate 动态设置最大值最小值
一般设置最大、最小值是这么设置的,直接给max赋值一个字符串
laydate.render({
elem: '#beginTime',
type: 'datetime',
btns: ['confirm','clear'],
format: 'yyyy-MM-dd HH:mm:ss',
max:'2020-01-01 12:00:00'
}
因为layui.laydate无法重新渲染,动态修改最大最小值。
修改如下:
let begT = laydate.render({
elem: '#beginTime',
type: 'datetime',
btns: ['confirm','clear'],
format: 'yyyy-MM-dd HH:mm:ss',
done: function(value, date, endDate) {
endT.config.min={
year:date.year,
month:date.month-1,
date:date.date,
hours:date.hours,
minutes:date.minutes,
seconds:date.seconds
}
}
let endT = laydate.render({
elem: '#endTime',
type: 'datetime',
btns: ['confirm','clear'],
format: 'yyyy-MM-dd HH:mm:ss',
done: function(value, date, endDate) {
begT.config.max={
year:date.year,
month:date.month-1,
date:date.date,
hours:date.hours,
minutes:date.minutes,
seconds:date.seconds
}
}
});