demo1.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <title>layDate 功能演示一</title>
  2. <div class="layui-card layadmin-header">
  3. <div class="layui-breadcrumb" lay-filter="breadcrumb">
  4. <a lay-href="">主页</a>
  5. <a><cite>组件</cite></a>
  6. <a><cite>日期时间</cite></a>
  7. </div>
  8. </div>
  9. <div class="layui-fluid">
  10. <div class="layui-row layui-col-space15">
  11. <div class="layui-col-md12">
  12. <div class="layui-card">
  13. <div class="layui-card-header">常规用法</div>
  14. <div class="layui-card-body" pad15>
  15. <div class="layui-form">
  16. <div class="layui-form-item">
  17. <div class="layui-inline">
  18. <label class="layui-form-label">中文版</label>
  19. <div class="layui-input-inline">
  20. <input type="text" class="layui-input" id="test-laydate-normal-cn" placeholder="yyyy-MM-dd">
  21. </div>
  22. </div>
  23. <div class="layui-inline">
  24. <label class="layui-form-label">国际版</label>
  25. <div class="layui-input-inline">
  26. <input type="text" class="layui-input" id="test-laydate-normal-en" placeholder="yyyy-MM-dd">
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. </div>
  34. <div class="layui-col-md12">
  35. <div class="layui-card">
  36. <div class="layui-card-header">五大选择器</div>
  37. <div class="layui-card-body" pad15>
  38. <div class="layui-form" wid100>
  39. <div class="layui-form-item">
  40. <div class="layui-inline">
  41. <label class="layui-form-label">年选择器</label>
  42. <div class="layui-input-inline">
  43. <input type="text" class="layui-input" id="test-laydate-type-year" placeholder="yyyy">
  44. </div>
  45. </div>
  46. <div class="layui-inline">
  47. <label class="layui-form-label">年月选择器</label>
  48. <div class="layui-input-inline">
  49. <input type="text" class="layui-input" id="test-laydate-type-month" placeholder="yyyy-MM">
  50. </div>
  51. </div>
  52. <div class="layui-inline">
  53. <label class="layui-form-label">日期选择器</label>
  54. <div class="layui-input-inline">
  55. <input type="text" class="layui-input" id="test-laydate-type-date" placeholder="yyyy-MM-dd">
  56. </div>
  57. </div>
  58. <div class="layui-inline">
  59. <label class="layui-form-label">时间选择器</label>
  60. <div class="layui-input-inline">
  61. <input type="text" class="layui-input" id="test-laydate-type-time" placeholder="HH:mm:ss">
  62. </div>
  63. </div>
  64. <div class="layui-inline">
  65. <label class="layui-form-label">日期时间选择器</label>
  66. <div class="layui-input-inline">
  67. <input type="text" class="layui-input" id="test-laydate-type-datetime" placeholder="yyyy-MM-dd HH:mm:ss">
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. <div class="layui-col-md12">
  76. <div class="layui-card">
  77. <div class="layui-card-header">范围选择</div>
  78. <div class="layui-card-body" pad15>
  79. <div class="layui-form" wid100>
  80. <div class="layui-form-item">
  81. <div class="layui-inline">
  82. <label class="layui-form-label">日期范围</label>
  83. <div class="layui-input-inline">
  84. <input type="text" class="layui-input" id="test-laydate-range-date" placeholder=" - ">
  85. </div>
  86. </div>
  87. <div class="layui-inline">
  88. <label class="layui-form-label">年范围</label>
  89. <div class="layui-input-inline">
  90. <input type="text" class="layui-input" id="test-laydate-range-year" placeholder=" - ">
  91. </div>
  92. </div>
  93. <div class="layui-inline">
  94. <label class="layui-form-label">年月范围</label>
  95. <div class="layui-input-inline">
  96. <input type="text" class="layui-input" id="test-laydate-range-month" placeholder=" - ">
  97. </div>
  98. </div>
  99. <div class="layui-inline">
  100. <label class="layui-form-label">时间范围</label>
  101. <div class="layui-input-inline">
  102. <input type="text" class="layui-input" id="test-laydate-range-time" placeholder=" - ">
  103. </div>
  104. </div>
  105. <div class="layui-inline">
  106. <label class="layui-form-label">日期时间范围</label>
  107. <div class="layui-input-inline">
  108. <input type="text" class="layui-input" id="test-laydate-range-datetime" placeholder=" - ">
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. </div>
  116. <div class="layui-col-md12">
  117. <div class="layui-card">
  118. <div class="layui-card-header">自定义格式</div>
  119. <div class="layui-card-body" pad15>
  120. <div class="layui-form" wid100>
  121. <div class="layui-form-item">
  122. <div class="layui-inline">
  123. <label class="layui-form-label">请选择日期</label>
  124. <div class="layui-input-inline">
  125. <input type="text" class="layui-input" id="test-laydate-format-date1" placeholder="yyyy年MM月dd日">
  126. </div>
  127. </div>
  128. <div class="layui-inline">
  129. <label class="layui-form-label">请选择日期</label>
  130. <div class="layui-input-inline">
  131. <input type="text" class="layui-input" id="test-laydate-format-date2" placeholder="dd/MM/yyyy">
  132. </div>
  133. </div>
  134. <div class="layui-inline">
  135. <label class="layui-form-label">请选择月份</label>
  136. <div class="layui-input-inline">
  137. <input type="text" class="layui-input" id="test-laydate-format-month" placeholder="yyyyMM">
  138. </div>
  139. </div>
  140. <div class="layui-inline">
  141. <label class="layui-form-label">请选择时间</label>
  142. <div class="layui-input-inline">
  143. <input type="text" class="layui-input" id="test-laydate-format-time" placeholder="H点m分">
  144. </div>
  145. </div>
  146. <div class="layui-inline">
  147. <label class="layui-form-label">请选择范围</label>
  148. <div class="layui-input-inline">
  149. <input type="text" class="layui-input" id="test-laydate-format-range1" placeholder=" ~ ">
  150. </div>
  151. </div>
  152. <div class="layui-inline">
  153. <label class="layui-form-label">请选择范围</label>
  154. <div class="layui-input-inline">
  155. <input type="text" class="layui-input" id="test-laydate-format-range2" placeholder="开始 到 结束">
  156. </div>
  157. </div>
  158. </div>
  159. </div>
  160. </div>
  161. </div>
  162. </div>
  163. <div class="layui-col-md12">
  164. <div class="layui-card">
  165. <div class="layui-card-header">同时绑定多个</div>
  166. <div class="layui-card-body" pad15>
  167. <div class="layui-form" wid100>
  168. <div class="layui-form-item">
  169. <div class="layui-inline">
  170. <input type="text" class="layui-input test-laydate-item" placeholder="yyyy-MM-dd">
  171. </div>
  172. <div class="layui-inline">
  173. <input type="text" class="layui-input test-laydate-item" placeholder="yyyy-MM-dd">
  174. </div>
  175. <div class="layui-inline">
  176. <input type="text" class="layui-input test-laydate-item" placeholder="yyyy-MM-dd">
  177. </div>
  178. </div>
  179. </div>
  180. </div>
  181. </div>
  182. </div>
  183. </div>
  184. </div>
  185. <script>
  186. layui.use(['admin', 'laydate'], function(){
  187. var laydate = layui.laydate;
  188. //示例代码
  189. //常规用法
  190. laydate.render({
  191. elem: '#test-laydate-normal-cn'
  192. });
  193. //国际版
  194. laydate.render({
  195. elem: '#test-laydate-normal-en'
  196. ,lang: 'en'
  197. });
  198. //年选择器
  199. laydate.render({
  200. elem: '#test-laydate-type-year'
  201. ,type: 'year'
  202. });
  203. //年月选择器
  204. laydate.render({
  205. elem: '#test-laydate-type-month'
  206. ,type: 'month'
  207. });
  208. //日期选择器
  209. laydate.render({
  210. elem: '#test-laydate-type-date'
  211. //,type: 'date' //type 默认为 date,所以可不填
  212. });
  213. //时间选择器
  214. laydate.render({
  215. elem: '#test-laydate-type-time'
  216. ,type: 'time'
  217. });
  218. //日期时间选择器
  219. laydate.render({
  220. elem: '#test-laydate-type-datetime'
  221. ,type: 'datetime'
  222. });
  223. //日期范围
  224. laydate.render({
  225. elem: '#test-laydate-range-date'
  226. ,range: true
  227. });
  228. //年范围
  229. laydate.render({
  230. elem: '#test-laydate-range-year'
  231. ,type: 'year'
  232. ,range: true
  233. });
  234. //年月范围
  235. laydate.render({
  236. elem: '#test-laydate-range-month'
  237. ,type: 'month'
  238. ,range: true
  239. });
  240. //时间范围
  241. laydate.render({
  242. elem: '#test-laydate-range-time'
  243. ,type: 'time'
  244. ,range: true
  245. });
  246. //日期时间范围
  247. laydate.render({
  248. elem: '#test-laydate-range-datetime'
  249. ,type: 'datetime'
  250. ,range: true
  251. });
  252. //自定义格式
  253. laydate.render({
  254. elem: '#test-laydate-format-date1'
  255. ,format: 'yyyy年MM月dd日'
  256. });
  257. laydate.render({
  258. elem: '#test-laydate-format-date2'
  259. ,format: 'dd/MM/yyyy'
  260. });
  261. laydate.render({
  262. elem: '#test-laydate-format-month'
  263. ,type: 'month'
  264. ,format: 'yyyyMM'
  265. });
  266. laydate.render({
  267. elem: '#test-laydate-format-time'
  268. ,type: 'time'
  269. ,format: 'H点m分'
  270. });
  271. laydate.render({
  272. elem: '#test-laydate-format-range1'
  273. ,range: '~'
  274. });
  275. laydate.render({
  276. elem: '#test-laydate-format-range2'
  277. ,type: 'datetime'
  278. ,range: '到'
  279. ,format: 'yyyy年M月d日H时m分s秒'
  280. });
  281. //同时绑定多个
  282. lay('.test-laydate-item').each(function(){
  283. laydate.render({
  284. elem: this
  285. ,trigger: 'click'
  286. });
  287. });
  288. });
  289. </script>