Web开发之使用【easyui】快速搭建管理员主界面
大家好呀,我是【小阿飞_】😜
今天来给大家分享如何使用easyui这个前端框架快速搭建管理员主界面
先介简单绍一下easyui
又叫Jquery EasyUI,是基于Jquery的界面框架插件,提供了丰富的界面功能,方便快速开发Web界面程序
easyui的主要结构:
目前easyui的官方网站已经下架,但是大家想使用easyui的话可以去搜官方文档之类的关键字
比如本期文章所使用的框架就是在【jQuery EasyUI 1.5API 中文版】中找到的👇
easyui和前两期文章中的bootstrap,以及Ant Design、Vue都是比较常用的前端UI(界面)
管理员界面以简洁、方便操作为主,刚好easyui中提供了一个Layout布局很适合用来快速搭建管理员主界面(代码和使用方法都可以在【jQuery EasyUI 1.5API 中文版】中找到)👇👇
在编写之前要将easyui的文件复制到项目中:
最终实现代码:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> <!-- min:压缩版,导入js,css $代表jquery --> <script src="${pageContext.request.contextPath}/jquery-easyui-1.5.5.2/jquery.min.js"></script> <script src="${pageContext.request.contextPath}/jquery-easyui-1.5.5.2/jquery.easyui.min.js"></script> <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/jquery-easyui-1.5.5.2/themes/default/easyui.css"> <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/jquery-easyui-1.5.5.2/themes/icon.css"> </head> <body class="easyui-layout"> <!--regin位置--> <div data-options="region:north,title:网站信息,collapsible:false" style="height:100px;"></div> <div data-options="region:south,title:赞助链接,collapsible:false" style="height:100px;"></div> <div data-options="region:west,title:菜单,split:true" style="width:20%;"> <ul id="sidebarTree"></ul> </div> <div data-options="region:center,title:主体部分" style="padding:5px;background:#eee;"></div> <script> $("#sidebarTree").tree({ url: "${pageContext.request.contextPath}/sidebarTree.js", lines: true }) </script> </body> </html>
js代码
[ { "id": 1, "text": "商品管理", "attributes": { "pid": 0 }, "children": [ { "id": 2, "text": "商品管理01", "attributes": { "pid": 1 } }, { "id": 3, "text": "商品管理02", "attributes": { "pid": 1 } } ] }, { "id": 10, "text": "类别管理", "attributes": { "pid": 0 }, "children": [ { "id": 11, "text": "类别管理01", "attributes": { "pid": 10 } }, { "id": 12, "text": "类别管理02", "attributes": { "pid": 10 } } ] } ]
最终效果: