abstract:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>home页面</title> <link rel="stylesheet"&nbs
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>home页面</title> <link rel="stylesheet" href="../../后台模板/static/plugins/layui/css/layui.css"> <script src="../admins/Admin/static/plugins/layui/layui.js"></script> <style> .header{ width:100%; height: 50px; line-height: 50px; background: #2e6da4; color:#ffffff; } .title{ margin-left: 20px; font-size: 20px; } .userinfo{ float: right; margin-right: 10px; } .userinfo a{ color:#ffffff; } .menu{ width: 200px; background: #333744; position: absolute; } .main{ position: absolute; left: 200px; right: 0px; } .layui-collapse{ border: none; } .layui-colla-item{ border-top: none; } .layui-colla-title{ background: #42485b; color:#ffffff; } .layui-colla-content{ border-top: none; padding: 0px; } iframe{ width:100%; height:100%; } </style> </head> <body> <!-- 头部区 --> <div class="header"> <span class="title">JD京东商城--后台管理系统</span> <span class="userinfo"> admin[系统管理员]<span> <a href="javascript:;" onclick="logout()">退出</a></span></span> </div> <!-- 功能区 --> <div class="menu" id="menu"> <div class="layui-collapse" lay-accordion> <div class="layui-colla-item"> <h2 class="layui-colla-title">图片管理</h2> <div class="layui-colla-content layui-show"> <ul class="layui-nav layui-nav-tree" lay-filter="test"> <li class="layui-nav-item"><a href="javascript:;"onclick="menuFire(this)"src="../../后台模板/admins/imagevoid.html">上传图片</a></li> <li class="layui-nav-item"><a href="javascript:;"onclick="menuFire(this)" src="../../后台模板/admins/admin.html" >管理员列表</a></li> </ul> </div> </div> <div class="layui-colla-item"> <h2 class="layui-colla-title">权限管理</h2> <!-- layui-shows是展开的 --> <div class="layui-colla-content"> <ul class="layui-nav layui-nav-tree" lay-filter="test"> <li class="layui-nav-item"><a href="javascript:;"onclick="menuFire(this)" src="../../后台模板/admins/menu.html">菜单管理</a></li> <li class="layui-nav-item"><a href="javascript:;" onclick="menuFire(this)"src="Roles.html">角色管理</a></li> </ul> </div> </div> <div class="layui-colla-item"> <h2 class="layui-colla-title">系统设置</h2> <div class="layui-colla-content "> <ul class="layui-nav layui-nav-tree" lay-filter="test"> <li class="layui-nav-item"><a href="javascript:;"onclick="menuFire(this)"src="../../后台模板/admins/imagevoid.html">图片管理</a></li> </ul> </div> </div> <div class="layui-colla-item"> <h2 class="layui-colla-title">商品分类</h2> <div class="layui-colla-content"> <ul class="layui-nav layui-nav-tree" lay-filter="test"> <li class="layui-nav-item"><a href="javascript:;"onclick="menuFire(this)"src="../../后台模板/admins/cates.html">分类列表</a></li> </ul> </div> </div> <div class="layui-colla-item"> <h2 class="layui-colla-title">产品管理</h2> <div class="layui-colla-content"> <ul class="layui-nav layui-nav-tree" lay-filter="test"> <li class="layui-nav-item"><a href="javascript:;"onclick="menuFire(this)"src="../../后台模板/admins/product.html">产品列表</a></li> </ul> </div> </div> <div class="layui-colla-item"> <h2 class="layui-colla-title">幻灯片管理</h2> <div class="layui-colla-content"> <ul class="layui-nav layui-nav-tree" lay-filter="test"> <li class="layui-nav-item"><a href="javascript:;"onclick="menuFire(this)"src="../../后台模板/admins/slide.html">首页首屏</a></li> </ul> </div> </div> </div> </div> <!-- 主体区 --> <div class="main"> <iframe src="../../后台模板/admins/welcome.html" frameborder="0" srclling="0" onload="resetMainHeight(this)"></iframe> </div> <script> layui.use(['element', 'layer'], function(){ var element = layui.element; layer = layui.layer; $=layui.jquery resetMenuHeight() }); function logout(){ layer.confirm('您确定要退出吗?', { // 弹出层icon小图标添加0-6个样式后面别忘了逗号哦! icon:1, //可以无限个按钮 btn: ['确定', '取消'] }, function(index, layero){ //按钮【按钮一】的回调 }, function(index){ //按钮【按钮二】的回调 }); } // 重新设置meun侧导航的高度 function resetMenuHeight(){ // 以下这个方法是用来获取到元素容器的总高度,减去导航的50高度 var height=document.documentElement.clientHeight-50 // 以下方法还要在第125行调用下jQuery方法 $('#menu').height(height); } //菜单点击 function menuFire(obj){ //获取url var src=$(obj).attr('src') //改变框架内的页面地址 $('iframe').attr('src',src) } //以下函数方法用于设置iframe框架自适应大小 function resetMainHeight(obj){ var height = parent.document.documentElement.clientHeight-53; $(obj).parent('div').height(height) } </script> </body> </html>
图片上传页面:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <link rel="stylesheet" href="../../后台模板/static/plugins/layui/css/layui.css"> <script src="../../后台模板/static/plugins/layui/layui.js"></script> <title>admin管理员</title> <style> .header span{ background: #009688; color: #fff; padding: 10px; margin-left: 30px; line-height: 32px; } .header{ border-bottom:2px solid #009688; margin: 0 0 10px; } </style> </head> <body style="padding:10px;"> <div class="header"> <span>图片管理</span> </div> <form class="layui-form" action=""> <div class="layui-form-item"> <label class="layui-form-label">选择框</label> <div class="layui-input-inline"> <select name="city" lay-verify="required"> <option value=""></option> <option value="0">北京</option> <option value="1">上海</option> <option value="2">广州</option> <option value="3">深圳</option> <option value="4">杭州</option> </select> <div class="layui-unselect layui-form-select"> <div class="layui-select-title"> <input type="text" placeholder="请选择" value="" readonly="" class="layui-input layui-unselect"> <i class="layui-edge"></i> </div> <dl class="layui-anim layui-anim-upbit"> <dd lay-value="" class="layui-select-tips">请选择</dd> <dd lay-value="0" class="">北京</dd> <dd lay-value="1" class="">上海</dd> <dd lay-value="2" class="">广州</dd> <dd lay-value="3" class="">深圳</dd> <dd lay-value="4" class="">杭州</dd> </dl> </div> </div> </div> <div class="layui-form-item"> <label class="layui-form-label">商品类目</label> <div class="layui-input-inline"> <input type="password" name="password" class="layui-input"> </div> </div> <div class="layui-form-item"> <label class="layui-form-label">商品价格</label> <div class="layui-input-inline"> <input type="password" name="password" class="layui-input"> </div> </div> <div class="layui-form-item"> <label class="layui-form-label">上传图片</label> <button type="button" class="layui-btn" id="test1"> <i class="layui-icon"></i>上传图片 </button> </div> <div class="layui-form-item layui-form-text" style="width:420px;"> <label class="layui-form-label">文本域</label> <div class="layui-input-block"> <textarea name="desc" placeholder="请输入内容" class="layui-textarea"></textarea> </div> </div> <div class="layui-form-item"> <button class="layui-btn" style="margin-left:110px;">保存</button> </div> </form> <script> //Demo layui.use('form', function(){ var form = layui.form; }); // 图片上传 layui.use('upload', function(){ var upload = layui.upload; //执行实例 var uploadInst = upload.render({ elem: '#test1' //绑定元素 ,url: '/upload/' //上传接口 ,done: function(res){ //上传完毕回调 } ,error: function(){ //请求异常回调 } }); }); </script> </body> </html>
<script> layui.use(['element', 'layer'], function(){ var element = layui.element; layer = layui.layer; $=layui.jquery resetMenuHeight() }); function logout(){ layer.confirm('您确定要退出吗?', { // 弹出层icon小图标添加0-6个样式后面别忘了逗号哦! icon:1, //可以无限个按钮 btn: ['确定', '取消'] }, function(index, layero){ //按钮【按钮一】的回调 }, function(index){ //按钮【按钮二】的回调 }); } // 重新设置meun侧导航的高度 function resetMenuHeight(){ // 以下这个方法是用来获取到元素容器的总高度,减去导航的50高度 var height=document.documentElement.clientHeight-50 // 以下方法还要在第125行调用下jQuery方法 $('#menu').height(height); } //菜单点击 function menuFire(obj){ //获取url var src=$(obj).attr('src') //改变框架内的页面地址 $('iframe').attr('src',src) } //以下函数方法用于设置iframe框架自适应大小 function resetMainHeight(obj){ var height = parent.document.documentElement.clientHeight-53; $(obj).parent('div').height(height) } </script>
最难的就是js部分,这些写的一些函数方法啊,还是不太习惯。
Correcting teacher:韦小宝Correction time:2019-01-07 09:46:11
Teacher's summary:往后学习layui中还有很多不一样的方法呢 layui把很多基础的方法都重新定义了 不过多写几遍还是很容易掌握的