layui-JQuery犯过的错误

所有的弹出层都显示在页面的最下面

解决方法:头文件处添加
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">

获取 layer.open 弹出的子层中的元素

var iframeWin = window[layero.find('iframe')[0]['name']];//得到iframe页的窗口对象,执行iframe页的方法
var content = layero.find("iframe")[0].contentWindow.$(".layui-input").val();
console.log(iframeWin.$(".layui-input").val());

将 layer.open 弹出层设置为圆角

.layui-layer{border-radius:20px;}
.layui-layer-title{border-radius: 20px;}

动态添加layui元素时 需要重新渲染 通过String html添加

//form 表单中的 需要 
layui.use(['layer','laydate','form'], function(){
    var layer = layui.layer, form = layui.form, laydate = layui.laydate;
    form.render();//layui 样式重新渲染
});
//侧边栏的需要
layui.use(['layer','laydate','element'], function(){
    var layer = layui.layer,element=layui.element;
    element.render();//layui 样式重新渲染
});

引用layui图标

<link th:href="@{/layui/css/layui.css}"  rel="stylesheet"/>
<i class="layui-icon layui-icon-set-fill"></i>
可以通过font-size和color属性定义图标的大小和颜色,
layui-icon
让图标旋转
<div  class="layui-icon layui-icon-loading layui-icon layui-anim layui-anim-rotate layui-anim-loop"></div>
或者<i></i>标签也可以

页面等待

var waitindex = layer.load(0,{shade: [0.2, '#393D49']}, {shadeClose: true}); //0代表加载的风格,支持0-2

弹出

询问
layer.confirm("<div style='width: 100%;height: 100%'><div style='text-align: center;padding-top: 10%;'>是否确定删除?</div></div>",
{title : ['提示','font-size:18px;font-family:Microsoft YaHei;background-color:white;border-bottom:0px;font-weight: 550;'],btnAlign: 'c',skin : "my-skin",area:['350px','240px'],shade: [0.2, '#393D49'],resize :false,
btn: ['确定', '取消'] //可以无限个按钮
}, function(index){

}, function(index){
layer.close(index);
});
弹出
layer.alert("<div style='width: 100%;height: 100%'><div style='margin-left: 25%;'>保存成功!</div></div>", {icon: 1,title : '提示',btnAlign: 'c',btn: ['确定'],area:['350px','240px'],shade: [0.2, '#393D49'],resize :false,},function (index) {
var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
parent.layer.close(index); //再执行关闭
});
打开
使用layui.open({
});时

icon图标样式 

给layui的数据表格设置编号

//在页面中添加 xuhao
<table class="table table-bordered dataTable" id="infosShow" lay-filter="infosShow" >
</table>
<script type="text/html" id="xuhao">
    {{d.LAY_TABLE_INDEX+1}}
</script>
//在js中添加  templet: '#xuhao'
,cols: [[
{field:'aa', title:'序号',templet: '#xuhao', width: '5%' ,style:'font-size: 14px;color: #000;font-family: SimSun;font-weight: 500;',fixed:'right',align:'center',unresize:true}
,{fixed:'right', title:'操作', width:'30%' , toolbar: '#barDemo',align:'center',unresize:true,fixed:'right'}
]]

设置layui数据表格中的 表头样式

,done : function(res, curr, count) {
    //如果是异步请求数据方式,res即为你接口返回的信息。
    //如果是直接赋值的方式,res即为:{data: [], count: 99} data为当前页数据、count为数据总长度
    //修改表头样式
    $("thead").find("tr").find("th").each(function (index, element) {
        $(element).css("color",'#000');
        $(element).css("font-size",'16px');
        $(element).css("font-family",'SimSun');
        $(element).css("font-weight",'600');
    });
}

使用模板引擎 来进行按钮是否显示

<script type="text/html" id="barDemo">
    <a class="applyOperate cmcc_btn cmcc_btn_stress" lay-event="load">下载</a>
    {{# if(d.itemAuditStatus == 1 ){ }}
        <a class="applyOperate cmcc_btn cmcc_btn_stress" style="margin-left: 20px;" lay-event="infoShow">明细查询</a>
    {{# } }}
</script>

进行表格分页

,page: { //支持传入 laypage 组件的所有参数(某些参数除外,如:jump/elem) - 详见文档
layout: [ 'prev', 'page', 'next', 'skip','limit', 'count'] //自定义分页布局
,groups: 5 //只显示 1 个连续页码
}

通过后台获取数据 然后进行前端页面的多级表头设置

,cols: [[{field:'', type:'numbers' , rowspan:2 ,title:'序号', width: '3%' ,style:'font-size: 14px;color: #000;font-family: SimSun;font-weight: 500;',fixed:'right',align:'center',unresize:true}
        ,{field:'',title:'两层',width:'7%', rowspan:2 ,style:'font-size: 14px;color: #000;font-family: SimSun;font-weight: 500;',fixed:'right',align:'left',unresize:true}
        ,{field:'',title:'两层',width:'15%', rowspan:2 ,style:'font-size: 14px;color: #000;font-family: SimSun;font-weight: 500;',fixed:'right' ,align:'center',unresize:true}
        ,{title:'一层上',width:'75%',colspan : 7, style:'font-size: 14px;color: #000;font-family: SimSun;font-weight: 500;',fixed:'right' ,align:'center',unresize:true}
        ],[
        {field:'', title:'一层下1', width: '11%' ,style:'font-size: 14px;color: #000;font-family: SimSun;font-weight: 500;' ,align:'left',unresize:true}
        ,{field:'', title:'一层下2', width:'11%',style:'font-size: 14px;color: #000;font-family: SimSun;font-weight: 500;', align:'center',unresize:true}
        ,{field:'', title:'一层下3', width:'12%',style:'font-size: 14px;color: #000;font-family: SimSun;font-weight: 500;', align:'center',unresize:true}
        ,{field:'', title:'一层下4',width:'11%',style:'font-size: 14px;color: #000;font-family: SimSun;font-weight: 500;', align:'center',unresize:true}
        ,{field:'', title:'一层下5', width:'11%' , toolbar: '#barDemo',align:'center',unresize:true }
        ,{field:'', title:'一层下6', width: '12%' ,style:'font-size: 14px;color: #000;font-family: SimSun;font-weight: 500;', align:'left',unresize:true}
        ,{field:'', title:'一层下7', width:'7%',style:'font-size: 14px;color: #000;font-family: SimSun;font-weight: 500;',align:'center',unresize:true}
]]

弹出层 对父级页面进行修改 

var openindex = parent.layer.getFrameIndex(window.name); //获取窗口索引
console.log(openindex);
console.log(parent.$("#applyId").val());//获取父级页面中元素的值

 

### 关于智慧校园管理系统前端页面的代码示例 以下是基于 `Layui` 框架实现的一个简单的智慧校园管理系统前端页面代码示例。此示例展示了如何通过 Layui 创建一个基础的用户界面,包括导航栏、表格以及表单等功能模块。 #### 导航栏与布局 ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>智慧校园管理系统</title> <!-- 引入 Layui CSS --> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/layui@2.7.6/css/layui.css"> </head> <body class="layui-layout-body"> <div class="layui-layout layui-layout-admin"> <!-- 左侧菜单 --> <div class="layui-side layui-bg-black"> <div class="layui-side-scroll"> <ul class="layui-nav layui-nav-tree" lay-filter="test"> <li class="layui-nav-item"><a href="#">学生管理</a></li> <li class="layui-nav-item"><a href="#">教师管理</a></li> <li class="layui-nav-item"><a href="#">课程安排</a></li> <li class="layui-nav-item"><a href="#">成绩查询</a></li> </ul> </div> </div> <!-- 主体内容区域 --> <div class="layui-body"> <table id="studentTable" lay-filter="studentTable"></table> </div> <!-- 底部信息 --> <div class="layui-footer"> © 2023 智慧校园管理系统 - 版权所有 </div> </div> <!-- 引入 Layui JS --> <script src="https://cdn.jsdelivr.net/npm/layui@2.7.6/layui.js"></script> <script> // 初始化 Layui 组件 layui.use(['element', 'table'], function () { var element = layui.element; var table = layui.table; // 渲染表格组件 table.render({ elem: '#studentTable', height: 400, url: '/mock/studentData.json', // 数据接口地址 page: true, // 开启分页 cols: [[ {field: 'id', title: 'ID', width: 80}, {field: 'name', title: '姓名', width: 120}, {field: 'age', title: '年龄', width: 100}, {field: 'class', title: '班级', width: 150} ]] }); }); </script> </body> </html> ``` 上述代码实现了以下功能: - 使用 Layui 提供的左侧导航栏展示不同功能模块。 - 利用表格组件渲染学生数据列表,并支持分页显示[^1]。 #### 表单提交示例 如果需要创建一个新的学生记录,可以设计如下表单: ```html <form class="layui-form" action="/submitStudent" method="post"> <div class="layui-form-item"> <label class="layui-form-label">姓名</label> <div class="layui-input-block"> <input type="text" name="name" required lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input"> </div> </div> <div class="layui-form-item"> <label class="layui-form-label">年龄</label> <div class="layui-input-block"> <input type="number" name="age" required lay-verify="required|number" placeholder="请输入年龄" autocomplete="off" class="layui-input"> </div> </div> <div class="layui-form-item"> <label class="layui-form-label">班级</label> <div class="layui-input-block"> <select name="class" lay-verify="required"> <option value="">请选择班级</option> <option value="ClassA">一年级一班</option> <option value="ClassB">二年级二班</option> </select> </div> </div> <div class="layui-form-item"> <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button> </div> </form> ``` 该表单利用了 Layui 的验证机制来确保输入的有效性[^1]。 --- ### 系统帮助文档概述 为了方便用户快速上手智慧校园管理系统,可提供一份简洁明了的帮助手册。主要内容应包括以下几个方面: 1. **系统登录流程**:描述管理员或用户的登录方式及其权限范围。 2. **主要功能介绍**:详细介绍各个模块的功能及操作方法。 3. **常见问题解答 (FAQ)**:列举并解决可能遇到的技术难题。 4. **技术支持联系方式**:提供联系渠道以便及时解决问题。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

封神尘

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值