使用方式

<link rel="stylesheet" href="/components/style/datepicker.css" type="text/css" />
<script defer src="/components/js/datepicker.js" type="text/javascript"></script>

日期选择

<div class="st_date_editor st_input st_input_suffix" type="clearable" able-future change="handleDateChange">
  <input
    type="text"
    placeholder="选择日期"
    size="small"
    class="st_input_inner"
  />
  <span class="st_input_prefix">
    <i class="stIconFont icon-riqi"></i>
  </span>
</div>

时间段选择

<div
  class="st_date_editor st_input st_input_suffix"
  type="clearable"
  st-model="orderTime"
  default-time="00:00:00,23:59:59"
  value-format="timestamp"
  daterange
  able-future
>
  <input
    type="text"
    placeholder="开始时间"
    size="small"
    class="st_input_inner"
    key="0"
  />
  <span class="st_input_prefix">
    <i class="stIconFont icon-riqi"></i>
  </span>
  <span class="date_range_separator"></span>
  <input
    type="text"
    placeholder="结束时间"
    size="small"
    class="st_input_inner"
    key="1"
  />
</div>

属性

属性 说明 类型 可选值 默认值
st-model 数据绑定 string - -
change 输入值变化回调方法 string - -
disabled 是否禁用 - - -
size 尺寸 string medium/small/mini -
clearable 可清空 - - -
able-future 可选未来时间 - - -
default-time 起始时间和结束时间 string - 00:00:00,23:59:59
value-format 绑定值的格式 string 见日期格式 timestamp
daterange 时间段选择 - - -

日期格式

格式 含义 备注 举例
Y 年份 完整 4 位数字 2022
y 年份 仅末尾 2 位数字 22
m 月份 数字带前导零 01-12
n 月份 数字不带前导零 1-12
d 日期 月份中的第几天,有前导零 01-31
j 日期 月份中的第几天,无前导零 1-31
H 小时 24 小时格式,有前导零 00-23
G 小时 24 小时格式,无前导零 0-23
h 小时 12 小时格式,有前导零 00-12
g 小时 12 小时格式,无前导零 0-12
i 分钟 数字带前导零 00-59
s 数字带前导零 00-59
timestamp 时间戳 毫秒 1483326245000

属性添加位置请查看示例代码