1

clipboard.png
效果如图所示,可在https://www.layui.com/demo/的调试预览中执行以下代码查看效果。

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <title>Layui时间模块同页面显示多种时间样式</title>
  <link rel="stylesheet" href="//res.layui.com/layui/build/css/layui.css" media="all">
  <style>
    body{margin: 10px;}
  </style>
</head>
<body>

<div class="layui-input-inline pull-left">
  <input class="layui-input" placeholder="年-月" id="yearmonth">
</div>
<div class="layui-input-inline pull-left">
    <input class="layui-input" placeholder="起始日期" id="startTime">
</div>
<div class="layui-input-inline pull-left">
    <input class="layui-input" placeholder="截止日期" id="endTime">
</div>

<script src="//res.layui.com/layui/build/layui.js"></script>
<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        var options = {
             min: '2010-01-01 00:00:00',
             max: '2099-06-16 23:59:59',
             event : 'click',
             //format : 'YYYY-MM',
             istoday: false
         }
        document.getElementById('yearmonth').onclick = function(){
            options.elem = this;
            options.format = "YYYY-MM";
            laydate(options);
        };

        document.getElementById('startTime').onclick = function(){
            options.elem = this;
            options.format = "YYYY-MM-DD";
            laydate(options);
        };
        document.getElementById('endTime').onclick = function(){
            options.elem = this;
            options.format = "YYYY-MM-DD";
            laydate(options);
        };
    });
</script>
</body>
</html>

whol
4 声望0 粉丝