layui常见弹窗使用方法

1:confim类型使用方法

layui.use('layer', function(){

layer.confirm('是否立即上传卷宗信息?', {
    btn: ['是','否'],
    time: 200000, //20s后自动关闭

    },function(index){

                                                alert("这是点击确定按钮走的回调")

    layer.close(index);
  },function(){
     alert("这是点击取消按钮走的回调")
  });

})

2:open类型弹框,content参数可以是一个选择器也可以是一个路径

layer.open({
type : 1,
title : "借阅时间",
area : [ '450px', '300px' ],
content : $("#borrowCase"),
btn: ['确定', '取消'],
yes: function(index){
  alert("这是点击确定按钮走的回调")
},
btn2: function(){
   alert("这是点击取消按钮走的回调")
},
end:function(){
alert('这是点击任一按钮都会走的回调')
}

});

layui.use('layer',function(){
var layer=layui.layer;
layer.open({
type:2,
title:'新增字段信息',
area:['450px','300px'],
content: "dictionary/addFiled?dictionaryId="+dictionaryId//字段类型
})
})

3:msg类型

layer.msg('添加借阅成功', {
    time: 1500, //1500ms后自动关闭

  });

4:关闭弹窗

layer_close(index)关闭当前弹窗

parent.layer.closeAll()关闭所有的弹窗


猜你喜欢

转载自blog.csdn.net/ygy211715/article/details/79976559