您好,登錄后才能下訂單哦!
Layui是一個樣式比較豐富艷麗的UI框架,通過自學了相關api文檔,自己手工搭建了一個后臺管理頁面。頁面布局是常用的一套,上面是一個logo,左邊區域是一個導航,中間是內容tab頁,底部是版權信息,好了,看代碼吧!
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>黃寶康個人搭建的后臺管理頁面</title> <link rel="stylesheet" href="css/layui.css" rel="external nofollow" > <script src="layui.js"></script> </head> <body> <div class="layui-layout-admin"> <!--頭部--> <div class="layui-header"> <div class="layui-logo">Huang BaoKang</div> <ul class="layui-nav layui-layout-left"> <li class="layui-nav-item"><a href="javascript:void(0)" rel="external nofollow" >控制臺</a></li> <li class="layui-nav-item"><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >商品管理</a></li> <li class="layui-nav-item"> <a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >其他系統</a> <dl class="layui-nav-child"> <dd><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >郵件管理</a></dd> <dd><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >消息管理</a></dd> <dd><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >授權管理</a></dd> </dl> </li> </ul> <ul class="layui-nav layui-layout-right"> <li class="layui-nav-item"> <a href=""><img src=" rel="external nofollow" http://m.zhengjinfan.cn/images/0.jpg" class="layui-nav-img">Huang BaoKang</a> <dl class="layui-nav-child"> <dd><a href="">基本資料</a></dd> <dd><a href="">安全設置</a></dd> </dl> </li> </ul> </div> <!--左側--> <div class="layui-side layui-bg-black"> <div class="layui-side-scroll"> <ul class="layui-nav layui-nav-tree" lay-filter="hbkNavbar"> <li class="layui-nav-item"> <a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >基本元素</a> <dl class="layui-nav-child"> <dd lay-id="111"><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-options="{url:'test.html',title:'表格'}">表格</a></dd> <dd><a href="">表單</a></dd> <dd><a href="">導航欄</a></dd> </dl> </li> <li class="layui-nav-item layui-nav-itemed"> <a href="">組件</a> <dl class="layui-nav-child"> <dd><a href="">Navbar</a></dd> <dd><a href="">Tab</a></dd> <dd><a href="">OneLevel</a></dd> <dd><a href="">app.js主入口</a></dd> </dl> </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" id="container"> <div class="layui-tab" lay-filter="tabs" lay-allowClose="true"> <ul class="layui-tab-title"> <li class="layui-this">首頁</li> </ul> <div class="layui-tab-content"> <div class="layui-tab-item layui-show">首頁內容</div> </div> </div> </div> <!--底部--> <div class="layui-footer"> <center>黃寶康版權所有©Tel:18679758769</center> </div> </div> <script> //JavaScript代碼區域 layui.use('element', function(){ var element = layui.element; element.on('nav(hbkNavbar)',function(elem){ /*使用DOM操作獲取超鏈接的自定義data屬性值*/ var options = eval('('+elem.context.children[0].dataset.options+')'); var url = options.url; var title = options.title; element.tabAdd('tabs',{ title : title, content : '<iframe scrolling="auto" frameborder="0" src="'+url+'" ></iframe>', id : '111' }); }); /*使用下面的方式需要引用jquery*/ /* $('.layui-nav-child a').click(function () { var options = eval('('+$(this).data('options')+')'); var url = options.url; var title = options.title; element.tabAdd('tabs',{ title : title, content : '<iframe scrolling="auto" frameborder="0" src="'+url+'" ></iframe>' }); });*/ }); </script> </body> </html>
代碼布局都加入了相關注釋,很好理解,需要說明的是,中間增加Tab使用DOM元素獲取a標簽的data屬性,tab頁內容主體采用的iframe,真正項目應用中,只需要關注url,比如常用的后臺框架Jfinal,只需要render下即可。
頁面效果如下:(截圖時縮放了瀏覽器),項目只引入了layui的css和js,沒有第三方的,小伙伴們,可以參考哦,覺得不錯,記得點贊哦-
以上這篇使用Layui搭建后臺管理界面的操作方法就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持億速云。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。