弹出层-layui

type
0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
弹出层
//winIndex存储弹出层的index,以便关闭弹出层时使用
        function openWindow(document){
            winIndex = layer.open({
                id:"add" //唯一标识
                ,type: 1 //弹出层类型 http://www.layui.com/doc/modules/layer.html
                ,title:'' //标题 默认 ‘信息’
                ,area: ['500px'] //宽高  ['500px', '300px']
                ,offset: 'auto' //坐标 默认 auto-垂直水平居中
                ,content: document //可传入的值是灵活多变的,不仅可以传入普通的html内容,还可以指定DOM,更可以随着type的不同而不同
                ,btnAlign: 'r' //按钮右对齐。默认值,不用设置 r、c、l 右中左
                ,shade: 0 //不显示遮罩
                ,success:function(){
                    //弹出成功后do something
                }
                ,end:function(){
                    //do something无论是确认还是取消,只要层被销毁了,end都会执行,不携带任何参数。
                }
            });
        }
关闭
layer.close(winIndex);
        //当你在iframe页面关闭自身时,也就是type值为2时
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index);//关闭弹出层
        //如果关闭弹出框后需要在页面刷新数据时,可以写在end方法里。无论是确认还是取消,只要层被销毁了,end都会执行,不携带任何参数。
信息框
 layer.msg('只想弱弱提示');
        layer.msg('有表情地提示', {icon: 6})
        layer.msg("提示内容",{
            icon:1,//图标
            time:1000 //1秒关闭(如果不配置,默认是3秒)
        },function(){
            //do something
        });   
关闭弹出层时刷新父界面,如果是table数据修改了,记得重新加载表格,不然不会自动加载
table.reload('articleData',{})

或者

//父页面
    location.reload();
    //子页面
    parent.location.reload();

更多操作请参考 http://www.layui.com/doc/modules/layer.html

 
原文地址:https://www.cnblogs.com/xiaonangua/p/9172182.html