zoukankan      html  css  js  c++  java
  • layui 学习笔记(二) 日期选择器&图片放大

    1.时间选择器

      https://www.layui.com/laydate/

      https://www.layui.com/v1/demo/laydate.html

      ->起始日期不能大于截止日期,截止日期不能小于起始日期

    html:

    <div class="layui-inline">
           <input id="startDate" class="layui-input test-item" type="text"  placeholder="起始日期"/>
    </div>
    <div class="layui-inline">
           <input id="endDate" class="layui-input test-item" type="text" placeholder="截止日期"/>
    </div>

    js:

    //初始化时间
        layui.use('laydate', function(){
            var laydate = layui.laydate;
            /*lay('.test-item').each(function(){// 如果不需要大小的验证 就这样写就行了后面就不需要了
                laydate.render({
                    elem: this
                    ,trigger: 'click'
                });
            });*/
            var startDate = laydate.render({
                elem:'#startDate',
                type:'date',
            trigger:'click', btns: [
    'clear','confirm'], done:function(value,date){ if(value){ endDate.config.min={ year:date.year, month:date.month-1,//关键 date:date.date, hours:date.hours, minutes:date.minutes, seconds:date.seconds }; }else{ endDate.config.min=startDate.config.min; } } }); var endDate=laydate.render({ elem:'#endDate', type:'date',
           trigger:'click', btns: [
    'clear','confirm'], done:function(value,date){ if(value){ startDate.config.max={ year:date.year, month:date.month-1,//关键 date:date.date, hours:date.hours, minutes:date.minutes, seconds:date.seconds } }else{ startDate.config.max=endDate.config.max; } } }) });

    2. 放大图片

    //放大图片
        var showNatrualPic=function(img){// img 里写 onclick="showNatrualPic(this)"
            var width=img.naturalWidth;
            var height=img.naturalHeight;
            if((width>800||height>800)&&width>height){//超宽
                height=height*800/width;
                width=800;
            }else if((width>800||height>800)&&width<height){//超长
                width=width*800/height;
                height=800;
            }else if(width>800||height>800){//正方形
                width=800;
                height=800;
            }
            parent.layer.open({
                type: 1,
                title: false,
                closeBtn: 0,
                shadeClose: true,
                area: [width + 'px', height + 'px'], //宽高
                content: "<img src=" + img.src + " style=""+width+"px;height:"+height+"px" />",
                end:function(){
                }
            });
        }
    -------博客内容仅用于个人学习总结-------
  • 相关阅读:
    字符串(url)拼接变量
    elementUI table数据显示效果(二)
    异常(转)
    PHP 的异常处理、错误的抛出及错误回调函数 (转)
    详细解读PHP类的封装 (转)
    什么是抽象类
    什么是类,什么是对象,类和对象之间的关系
    魔术方法
    类的声名
    self
  • 原文地址:https://www.cnblogs.com/DarGi2019/p/12095036.html
Copyright © 2011-2022 走看看