日期时间组件
小于 1 分钟easyui
概述
设置默认
<!-- 硬编码方式设置默认 -->
<input id="start" class="easyui-datebox" data-options="label:'制单起始日期:',labelWidth:90,width:190,value:'2024-06-22'">
<!-- 编程方式设置默认 -->
<input id="start" class="easyui-datebox"
data-options="label:'制单起始日期:',labelWidth:90,width:190,value:(function(){
let date = new Date();
date.setMonth(date.getMonth()-1);
return getFirstDate(date);
})()">
<!-- 默认当天日期 -->
<input id="end" class="easyui-datebox" data-options="label:'制单终止日期:',labelWidth:90,width:190,value:getCurrentDate(0)">
获取值
带有时间的控件
$('#start1').datetimebox('getValue')
如果不带时间
$('#start1').datebox('getValue')
赋值
下面的方法 curMonthFirstDay 返回的日期对象,直接拿 firstDay 赋值给 datebox 会报错,需要转换为字符串类型的日期
const firstDay = curMonthFirstDay();
const today = dateToStr('yyyy-MM-dd',new Date());
const firstDayString = dateToStr('yyyy-MM-dd',firstDay);
$('#start').datebox('setValue',firstDayString);
$('#end').datebox('setValue',today);
