layui关闭弹出层的方法教程
时间:2023-01-10 23:44:19
layui怎么关闭弹出层?layui框架是个开源的前端工具模板,很多用户在使用layer弹框的时候会常常遇到关闭弹窗的问题,这里小编给大家分享下layui框架关闭弹出层的具体方法吧。
1、layer.close(index) - 关闭特定层
//当你想关闭当前页的某个层时
var index = layer.open();
var index = layer.alert();
var index = layer.load();
var index = layer.tips();
//正如你看到的,每一种弹层调用方式,都会返回一个index
layer.close(index); //此时你只需要把获得的index,轻轻地赋予layer.close即可
//如果你想关闭最新弹出的层,直接获取layer.index即可
layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
//当你在iframe页面关闭自身时
var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
parent.layer.close(index); //再执行关闭
2、layer.closeAll(type) - 关闭所有层
如果你很懒,你不想去获取index你只想关闭。那么closeAll真的可以帮上你。如果你不指向层类型的话,它会销毁掉当前页所有的layer层。当然,如果你只想关闭某个类型的层,那么你可以
layer.closeAll(); //疯狂模式,关闭所有层
layer.closeAll(‘dialog’); //关闭信息框
layer.closeAll(‘page’); //关闭所有页面层
layer.closeAll(‘iframe’); //关闭所有的iframe层
layer.closeAll(‘loading’); //关闭加载层
layer.closeAll(‘tips’); //关闭所有的tips层
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Excel中利用函数公式计算个人所得税的方法
wps怎么添加ppt背景
![](https://img.aspxhome.com/file/2023/0/53480_0s.jpg)
win7默认网关不可用_win7默认网关不可用的解决方法
![](https://img.aspxhome.com/file/2023/2/a287343_0s.png)
如何设置百度卫士开机启动项 百度卫士开机启动项设置教程
excel2016表格怎么插入日历?
![](https://img.aspxhome.com/file/2023/4/40184_0s.jpg )
主板短路有什么现象发生?主板短路能修好吗?
![](https://img.aspxhome.com/file/2023/6/a326119_0s.jpg)
WPS2019图片怎么进行垂直翻转
![](https://img.aspxhome.com/file/2023/7/a171107_0s.jpeg)
Win11磁盘占用100%怎么办?win11任务管理器显示磁盘占用100%
![](https://img.aspxhome.com/file/2023/27/a238349_0s.jpg)
WPS文字怎么设置标题格式教程
Win10系统怎么删除Thumbs.db文件?
![](https://img.aspxhome.com/file/2023/28/a245778_0s.jpg)
Win10卸载杀毒软件后Windows defender仍无法启动怎么办?
![](https://img.aspxhome.com/file/2023/26/a224961_0s.jpg)
Mac键盘进水了怎么办?苹果电脑键盘进水后维修办法介绍
![](https://img.aspxhome.com/file/2023/0/a215470_0s.jpg)
电脑版wps文档如何设置数字上标
![](https://img.aspxhome.com/file/2023/4/a183684_0s.png)
Win10无法连接到更新服务我们将稍后再试怎么办?
![](https://img.aspxhome.com/file/2023/6/50966_0s.png)
excel表格只读属性怎么取消
WPS文字 显示/隐藏功能区 动画教程
谷歌浏览器不提示保存密码怎么办
![](https://img.aspxhome.com/file/2023/9/a343166_0s.png)
Win7禁用IPV6协议,解决网游跳ping问题
Win8.1系统临死前终于干掉了XP系统
![](https://img.aspxhome.com/file/2023/3/a293578_0s.png)
电脑开机提示ravmond.exe应用程序错误的解决办法
![](https://img.aspxhome.com/file/2023/3/a299159_0s.jpg)