easyui怎么添加多个页面(用EasyUI绘制主界面)

首页常识更新时间:2023-08-31 09:46:04
1.引入资源包

在上一节中,我们把基本的框架都搭好了,用了Spring,SPringMVC。这一节,我们先来画页面,前端框架采用EasyUI来实现。

easyui是一种基于jQuery的用户界面插件集合,使用easyui我们就不需要写很多代码,只需要通过编写一些简单HTML标记,就可以定义用户界面。

现在,我们把easyui需要的资源包拷贝进来。

2.绘制主界面

界面的话,我们就用html来实现吧,在WebContent目录下新建一个页面叫index.html。

目录结构如下:

代码:

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>学生管理主界面</title> <!-- 引入EasyUI资源文件 --> <link rel="stylesheet" type="text/css" href="jquery-easyui-1.3.3/themes/default/easyui.css"> <link rel="stylesheet" type="text/css" href="jquery-easyui-1.3.3/themes/icon.css"> <script type="text/javascript" src="//img.anhuiqq.cn/jquery-easyui-1.3.3/jquery.min.js"></script> <script type="text/javascript" src="//img.anhuiqq.cn/jquery-easyui-1.3.3/jquery.easyui.min.js"></script> <script type="text/javascript" src="//img.anhuiqq.cn/jquery-easyui-1.3.3/locale/easyui-lang-zh_CN.js"></script> </head> <body> </body> </html>

现在,我们来画四个按钮:

<!-- 工具栏 --> <div id="toolbar"> <a href="javascript:openUserAddPage()" class="easyui-linkbutton" iconCls="icon-add" >新增用户</a> <a href="javascript:openUserModifyDialog()" class="easyui-linkbutton" iconCls="icon-edit" >编辑用户</a> <a href="javascript:delUser()" class="easyui-linkbutton" iconCls="icon-remove">删除用户</a> <a href="javascript:resetPassword()" class="easyui-linkbutton" iconCls="icon-modifyPassword">密码重置</a> </div>

可以看到每一个按钮都是用a标签来做的,我们给每一个a标签添加一个 easyui-linkbutton 的class,就可以实现这一效果:

同时,每一个按钮还有一个点击事件,对应的函数我们先不写,预留一个接口。

接下来,我们绘制搜索栏,到时候可以根据某些条件来查询学生数据。

代码:

<!-- 搜索栏 --> <div id="searchBox"> 用户名 <input type="text" id="username_search" size="20" onkeydown="if(event.keyCode==13) searchUser()"/> 昵称 <input type="text" id="nickname_search" size="20" onkeydown="if(event.keyCode==13) searchUser()"/> <a href="javascript:searchUser()" class="easyui-linkbutton" iconCls="icon-search" plain="true">搜索</a> </div>

自定义css样式:

#searchBox{ margin-top: 16px; background: #fff8f8; padding: 4px; font-size: 14px; width: 500px; }

页面效果:

最后,画数据列表,我们使用easyUI给我们提供的datagrid组件来实现:

<br> <!-- 数据列表 --> <table id="grid0" class="easyui-datagrid" title="用户列表" style="width:980px;height:550px" data-options="pagination:true,pageSize:10,rownumbers:true,fitColumns:true, singleSelect:false,collapsible:false,url:''"> <thead> <tr> <th data-options="field:'ck',checkbox:true"></th> <th data-options="field:'username',width:80">用户名</th> <th data-options="field:'password',width:100">密码</th> <th data-options="field:'nickname',width:120">昵称</th> <th data-options="field:'xb',width:0,hidden:true" >性别</th> <th data-options="field:'vip',width:0,hidden:true">贵族等级</th> <th data-options="field:'xb_displayname',width:80" >性别</th> <th data-options="field:'vip_displayname',width:80">贵族等级</th> <th data-options="field:'createtime',width:250"">创建时间</th> <th data-options="field:'updatetime',width:250">最后更新时间</th> </tr> </thead> </table>

最终效果:

打开浏览器访问:http://localhost/student/index.html 即可看到该页面。

本节我们就简单的画一个页面,下一讲我们继续写后台代码。

,
展开阅读全文
推荐内容
热门内容
热门文章

© 2007-2022 http://www.anhuiqq.cn,All Rights Reserved.