引用layer.js,官网:http://layer.layui.com/
常用属性:btn/icon/skin/time/content/yes(点击确认、提交)

常用窗体
.alert

layer.alert("内容");
layer.alert('墨绿风格,点击确认看深蓝', {
skin: 'layui-layer-molv'//样式类名
, closeBtn: 0
}, function () {
layer.alert('偶吧深蓝style', {
skin: 'layui-layer-lan'
, closeBtn: 0
, shift: 2 //动画类型
});
});

.confirm

layer.confirm('您是如何看待前端开发?',{
btn: ['重要', '奇葩'] //按钮
}, function () {
layer.msg('的确很重要', { icon: 1 });
}, function () {
layer.msg('也可以这样', {
time: 20000, //20s后自动关闭
btn: ['明白了', '知道了']
},function() {
layer.msg('明白就好', { time: 20000 });
},function() {
layer.msg('知道就好', { time: 20000 });
});
});

.msg

layer.msg('hello.');

.open 自定义窗口

layer.open({
type: 1,
skin: 'layui-layer-demo',//样式类名
btn: ["关闭"],
/*closeBtn: 0, //不显示关闭按钮*/
shift: 2,
shadeClose: true, //开启遮罩关闭
content: '内容'
});
layer.open({
type: 2,
title: 'layer mobile页',
shadeClose: true,
shade: 0.8,
area: ['700px','90%'],
content: 'http://layer.layui.com/mobile/'//iframe的url
});

.html

$("#layerOpen").html('<imgsrc="/images/loading.gif"/>正在努力为您搜索,请稍后...');

.load 加载

$("#layerOpen").load("/Order/ProductList");

.tips
关闭layer
用一个变量存储弹窗,在需要关闭的地方调用close方法

<div style="display:none;"id="layerOpen"></div>
var layerOpen = null; //弹窗变量
layerOpen=layer.open({
type: 1,
title: "查看XXX的详情",
area: ["1000px","600px"],
content: $("#layerOpen"),
cancel: function () {
$("#layerOpen").html("");
}
});
layer.close(layerOpen);

打开自定义页面

$("#layerOpen").html('<imgsrc="/images/loading.gif"/>正在努力为您搜索,请稍后...');
$("#layerOpen").load("/Controller/Action");
layerOpen = layer.open({
type: 1,
title: "选择XXX",
area: ["1000px","600px"],
content: $("#layerOpen"),
cancel: function () {
$("#layerOpen").html("");
}
});

加载页面
保存变量,打开页面赋值,关闭页面

//加载layer
var load = null;
$.ajax({
type: "POST",
url: "/Controller/Action",
data: {
"PKID":PKID,
"Path": path
},
beforeSend: function () {
load = layer.load(0, { shade:[0.3, '#000'] });//0代表加载的风格,支持0-2
},
success: function (result) {
if (load != null) {
layer.close(load);
}
layer.alert(result.Msg, '提示');
}
});

layerui的更多相关文章

  1. 【Javascript】好用的js弹层插件,layerUI

    官网:layerUI 中文手册:layerAPI

  2. layerUi与AJAX的一种思路

    javascript:function rep(id) { layer.confirm("确定要拒绝此认证吗?", { btn: ["确定", "取消 ...

  3. layerui如何隐藏按钮?

    https://www.layui.com/doc/modules/layer.html#btn 建议把 btn: ['取消'],btnAlign: 'c',yes: function (index) ...

  4. LayeruI Loadding Custom word

    var getTableResult = function (pageIndex, pageSize) { var index = layer.load(2, { content: '加载中..... ...

  5. layerui如何设置显示的位置?

    转自:http://www.layui.com/doc/modules/layer.html#offset layer.open({ type: 1,//默认:0 (0表示信息框,1表示页面层,2表示 ...

  6. Layerui 弹出层的位置设置

    距顶 offset: '300px' 例1: layer.msg("请先选择项!", { offset: '300px' });例2: layer.confirm("确定 ...

  7. layerui ios不适应问题

    .admin-main {-webkit-overflow-scrolling: touch; overflow: scroll; position: absolute; left: 0; top:  ...

  8. layerui上传文件

    参考: http://www.layui.com/doc/modules/upload.html <1> 文件上传(以下函数必须要在js文件加载时执行) upload.render({ e ...

  9. Turtle Online:致力于打造超接地气的PC前端架构,组件+API,快速搭建前端开发

    架构创作初衷 每当新开一个项目时,都会绞尽脑汁去考虑采用哪种框架:requirejs/seajs.jquery/zepto.backbone.easeUI/Bootstrap/AngularJS……, ...

随机推荐

  1. ios开发知识点补充

    一:self class,self superClass  super class  super superClass 的区别 新建SubPerson继承person,在SubPerson中打印如下: ...

  2. Android shape画圆点

    <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http: ...

  3. MouseGestureLahk

    http://cyber-furoshiki.com/win-mouse-gesture-l http://www.vector.co.jp/download/file/winnt/util/fh68 ...

  4. JS和CSS压缩部署,提高访问效率

    一直想把项目中的js和css压缩下,今天终于搞定了. 先说说几个注意的问题,目标影响着你对应的解决办法:1.压缩后的文件,是否要直接覆盖旧的文件2. 单个压缩文件重命名,还是整个目录换个名字,同时文件 ...

  5. [tmux] Zoom and resize to view a particular pane within tmux

    Sometimes you'll want to zoom in on a specific pane within a tmux window. We'll learn to use C-b z t ...

  6. SpringMVC ModelAndView跳转失效

    今天隔壁的兄弟遇到一个奇怪的问题,他写好了一个表单用post提交到了addNew.do 里面,然后利用 return new ModelAndView("forward:success.js ...

  7. WPF 在绘图控件(Shape)中添加文字 [2018.7.15]

    原文:WPF 在绘图控件(Shape)中添加文字 [2018.7.15] Q:使用Shape的子类Ellipse画一个圆,如何在圆中添加文字? A:Shape类中不包含Text属性.可使用Shape类 ...

  8. windows 下使用 virtualenv 创建虚拟环境

    virtualenv虚拟环境为每个项目隔离了一套运行类库,不同的项目在各自的虚拟环境中使用不同的类库,避免了将所有类库都安装到系统环境中导致的不同项目需要不同(版本)类库的问题,项目与项目之间的类库依 ...

  9. 多线程中的lock,Monitor.Wait和Monitor.Pulse

    我们知道lock实际上一个语法糖糖,C#编译器实际上把他展开为Monitor.Enter和Monitor.Exit,即: lock(lockObj) { //... } ////相当于(.Net4以前 ...

  10. Android官方教程翻译(6)——添加ActionBar

    The action bar allows you to add buttons for the most important action items relating to the app's c ...