zoukankan      html  css  js  c++  java
  • 前端开发

    layer用法

    1.layer提示框

    layer.msg("操作成功", {time:2000, icon:1}); //icon:0-2 
    

    2.ajax请求后成功刷新页面,失败提示信息(使用layer组件)

    $.ajax({
        type: "POST",
        data: json,
        contentType: 'application/json;charset=utf-8',
        url: "${ctx!}/admin/voucher/select/delete",
        success: function(msg){
            msg = JSON.parse(msg);
            if (msg.code == 0){
                layer.msg(msg.message, {icon:1, time: 2000}, function () {
                    window.location.reload();
                    //table.bootstrapTable("refresh");
                });
            } else {
                layer.msg(msg.message, {icon:2, time:2000})
            }
        }
    });
    

    3.layer确认框

    layer.confirm('是否确认删除?', {btn: ['确认','取消']},
        function(){
            $.ajax({
                type: "get",
                contentType: 'application/json;charset=utf-8',
                dataType: 'json',
                url: "${ctx!}/admin/warning/apply/del/" + id,
                success: function(msg){
                    if (msg.code == 0){
                        layer.msg(msg.message, {icon:1, time: 1000}, function () {
                            $table.bootstrapTable("refresh");
                            // window.location.reload();
                        });
                    } else {
                        layer.msg(msg.message, {icon:2, time:1000})
                    }
                }
            });
        },
        function () {
        }
    );
    

    4.layer中打开网页

    layer.open({
        type: 2,
        resize: true,
        skin: 'layui-layer-rim', //加上边框
        area: ['1000px', '800px'], //宽高
        content: "http://www.baidu.com"
    });
    

    5.关闭当前层

            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index);
    
    
  • 相关阅读:
    上古神器之Vim编辑器
    Git
    Git
    php之IP
    PHP常见错误汇总
    Redis教程(Windows)
    如何使用RSS
    (转)Spring Boot干货系列:(三)启动原理解析
    (转)Maven创建webapp项目无法修改web版本的问题
    (转)图文详解MyEclipse中新建Maven webapp项目的步骤
  • 原文地址:https://www.cnblogs.com/zhangnianlei/p/12239258.html
Copyright © 2011-2022 走看看