special-demo.html 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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" wid100>
  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-start" placeholder="开始日期">
  21. </div>
  22. <div class="layui-form-mid">
  23. -
  24. </div>
  25. <div class="layui-input-inline">
  26. <input type="text" class="layui-input" id="test-laydate-end" placeholder="结束日期">
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. <script>
  37. layui.use(['admin', 'laydate'], function(){
  38. var laydate = layui.laydate;
  39. //示例代码
  40. //开始日期
  41. var insStart = laydate.render({
  42. elem: '#test-laydate-start'
  43. ,min: 0
  44. ,done: function(value, date){
  45. //更新结束日期的最小日期
  46. insEnd.config.min = lay.extend({}, date, {
  47. month: date.month - 1
  48. });
  49. //自动弹出结束日期的选择器
  50. insEnd.config.elem[0].focus();
  51. }
  52. });
  53. //结束日期
  54. var insEnd = laydate.render({
  55. elem: '#test-laydate-end'
  56. ,min: 0
  57. ,done: function(value, date){
  58. //更新开始日期的最大日期
  59. insStart.config.max = lay.extend({}, date, {
  60. month: date.month - 1
  61. });
  62. }
  63. });
  64. });
  65. </script>