LayUI入门,以及介绍

news2024/10/6 2:30:29

                                            一.LayUI基本情况

1.LayUI介绍

Layui(流行于 layui.com)是一款轻量级的前端UI框架,专注于提供简洁、易用、灵活的界面组件和交互体验。它基于HTML5和CSS3技术,采用模块化开发的思想,提供了丰富的UI组件、常用的工具函数和灵活的扩展机制。

Layui的设计理念是“经典与创新的全面结合”,它提供了一套简洁、直观、易于上手的API,使得开发者能够快速搭建出美观、功能完善的前端界面。Layui的代码精简,文件体积小,加载速度快,非常适合开发响应式的Web应用程序。

Layui提供了丰富的组件,包括按钮、表单、表格、导航、选项卡、弹窗、富文本编辑器等等,这些组件具有一致的风格和交互体验,可以有效提高开发效率。同时,Layui还提供了丰富的工具函数和插件,如日期选择器、分页、上传组件等,方便开发者进行常见的操作和功能扩展。

除了提供基础的UI组件和工具函数,Layui还支持自定义主题和模块扩展。开发者可以根据自己的需求,自定义界面样式和交互效果。同时,Layui还支持模块化开发,开发者可以将自己的组件封装成模块,方便复用和扩展。

总之,Layui是一个功能强大、简单易用的前端UI框架,适用于各种类型的Web应用程序开发。它具有良好的兼容性和性能优势,可以帮助开发者快速构建出优秀的前端界面。

2. LayUI发展历史

Layui框架的诞生可以追溯到2016年。在这一年,一位名叫贤心的前端开发者提出了一种构想:希望能够通过一个简单、易用、高性能的前端框架来简化开发过程并提升开发效率。于是,他开始了Layui框架的开发。

贤心是一个热衷于前端开发的工程师,他在开发过程中积累了大量的经验和技巧。他希望通过将自己的经验整理归纳成一个前端框架,来帮助其他开发者快速开发出优秀的前端界面。

Layui在设计之初就坚持了一些原则,比如简洁易用、高效精简、模块化开发等。贤心精心设计了Layui的API和组件结构,使其能够提供一致的界面风格和交互效果,同时又具备灵活的扩展性。

Layui在发布后迅速获得了广泛的关注和认可。开发者们纷纷尝试使用Layui来开发自己的项目,并提供了大量的反馈和建议。贤心积极听取用户的意见,不断改进和完善框架,使其更加符合开发者的需求。

随着时间的推移,Layui逐渐成为了国内最受欢迎的前端框架之一。越来越多的开发者选择Layui来构建自己的项目,而Layui社区也迅速壮大起来。在社区的帮助下,Layui不断更新版本,提供越来越丰富和强大的功能。

至今,Layui已经发布了多个版本,每个版本都带来了新的特性和改进。Layui的成功离不开贤心的辛勤付出和广大开发者的支持。它不仅简化了前端开发的流程,还促进了前端开发者之间的交流和分享,成为了国内前端界的重要组成部分。(遗憾的是由于是开源的,在2021.10.13就停止更新了没有资金维护)


                       二.将Layui加入web项目中

1.搜索网址

    官方网站:https://www.layui.com/(已下线)
   参考地址:http://layui.org.cn/demo/index.html(已下线,非官网)

 2.下载文件,解压

 点击下载即可,不需要登陆账号

解压的文件就是这几个文件,我们需要的layui文件在layui包里

3.加入web项目

3.1导入layui包

 建立一个静态资源包,将我们的资源导入

3.2.在jsp中导入资源

link rel="stylesheet" href="${pageContext.request.contextPath }/static/js/layui/css/layui.css">
<!-- 引入 layui.js -->
<script src="${pageContext.request.contextPath}/static/js/layui/layui.js"></script>

在其中pageContext.request.contextPath作用是适用于任何的js,css,img等等导入

 3.3效果图

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<%@ include  file="common/header.jsp" %>
</head>
<body>
 
<!-- 你的 HTML 代码 -->
<script>
layui.use(['layer', 'form'], function(){
  var layer = layui.layer
  ,form = layui.form;
  
  layer.msg('Hello World');
});
</script> 
</body>
</html>

                                    三.利用LayUi实现登录注册

1.实现登录:

1.1首先编写jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="common/header.jsp"%>
<html>
<head>
<meta name="viewport"
	content="width=device-width,initial-scale=1.33,minimum-scale=1.0,maximum-scale=1.0">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
<title>会员登录-演示网站</title>
<meta http-equiv="Content-Language" content="zh-CN">
<link rel="stylesheet" rev="stylesheet"
	href="${pageContext.request.contextPath}/static/css/iconfont.css"
	type="text/css" media="all">
<link rel="stylesheet" rev="stylesheet"
	href="${pageContext.request.contextPath}/static/css/login.css"
	type="text/css" media="all">
<style>
body {
	color: #;
}

a {
	color: #;
}

a:hover {
	color: #;
}

.bg-black {
	background-color: #;
}

.tx-login-bg {
	background: url(${pageContext.request.contextPath}/static/images/bg.jpg)
		no-repeat 0 0;
}
</style>
</head>
<body class="tx-login-bg">
	<div class="tx-login-box">
		<div class="login-avatar bg-black">
			<i class="iconfont icon-wode"></i>
		</div>
		<ul class="tx-form-li row">
			<li class="col-24 col-m-24"><p>
					<input type="text" id="username" placeholder="登录账号"
						class="tx-input">
				</p></li>
			<li class="col-24 col-m-24"><p>
					<input type="password" id="password" placeholder="登录密码"
						class="tx-input">
				</p></li>
			<li class="col-24 col-m-24"><p class="tx-input-full">
					<button id="login" class="tx-btn tx-btn-big bg-black">登录</button>
				</p></li>
			<li class="col-12 col-m-12"><p>
					<a href="#" class="f-12 f-gray">新用户注册</a>
				</p></li>
			<li class="col-12 col-m-12"><p class="ta-r">
					<a href="#" class="f-12 f-gray">忘记密码</a>
				</p></li>
		</ul>
	</div>
	<script>
		layui.use([ 'layer', 'jqurey' ], function() {
			var layer = layui.layer, $ = layui.jqurey;

			$("#login").click(function() {
			$.ajax({
			url:'${pageContext.request.contextPath}/user.action?methodName=login',
			dataType:'json',
			data:{
				loginName:$("#username").val(),
				password:$("#password").val()
			},
			method:'post',
			sucess:function (data){
				if (data) {
					layer.alert('恭喜'+data.name+'登录成功',{icon:6});	
				}else {
					layer.alert('密码错误',{icon:6});
				}
			}
			});	
			
			})
		});
	</script>
</body>
</html>

 1.2编写实体,dao方法、

1.2.1实体

package com.lz.entity;

public class User {
	private long id;
	private String name;
	private String loginName;
	private String pwd;
	private long rid;
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "User [id=" + id + ", name=" + name + ", loginName=" + loginName + ", pwd=" + pwd + ", rid=" + rid + "]";
	}
	/**
	 * @return the id
	 */
	public long getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(long id) {
		this.id = id;
	}
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return the loginName
	 */
	public String getLoginName() {
		return loginName;
	}
	/**
	 * @param loginName the loginName to set
	 */
	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}
	/**
	 * @return the pwd
	 */
	public String getPwd() {
		return pwd;
	}
	/**
	 * @param pwd the pwd to set
	 */
	public void setPwd(String pwd) {
		this.pwd = pwd;
	}
	/**
	 * @return the rid
	 */
	public long getRid() {
		return rid;
	}
	/**
	 * @param rid the rid to set
	 */
	public void setRid(long rid) {
		this.rid = rid;
	}
	public User() {
		super();
	}
	public User(long id, String name, String loginName, String pwd, long rid) {
		super();
		this.id = id;
		this.name = name;
		this.loginName = loginName;
		this.pwd = pwd;
		this.rid = rid;
	}
}

1.2.2登录dao方法

/**
	 * 登录
	 * @param user
	 * @return
	 * @throws Exception
	 */
	public  User   login(User  user ) throws Exception {
		String  sql="select *from  t_oa_user  where loginName="+user.getLoginName()+"' and   pwd='"+user.getPwd()+"'  ";
		List<User> list = super.executeQuery(sql, User.class,null);
		if (list!=null&&list.size()==1) {
			return  list.get(0);
		}
		return   null;
	}

1.3实现登录,增加action

package com.lz.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.lz.dao.UserDao;
import com.lz.entity.User;
import com.zking.framework.ActionSupport;
import com.zking.framework.ModelDriver;
import com.zking.util.ResponseUtil;

public class UserAction extends ActionSupport implements ModelDriver<User> {
	private User user = new User();
	private UserDao userdao = new UserDao();

	public void login(HttpServletRequest req, HttpServletResponse resp) {
		try {
			User u = userdao.login(user);
			ResponseUtil.writeJson(resp, u);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
	// 增加 重定向 book.action
		public String add(HttpServletRequest req, HttpServletResponse resp)  {
			try {
				int add = userdao.add(user);
				
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			return "toList";
		}

	@Override
	public User getModel() {
		// TODO Auto-generated method stub
		return user;
	}

}

 1.4配置xml

	
	<action  path="/user"  type="UserAction">
	<forward name="toList" path="/user.action?methodName=list"
			redirect="true" />
	</action

2.注册

2.1编写jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="common/header.jsp"%>
<html>
<head>
<meta name="viewport"
	content="width=device-width,initial-scale=1.33,minimum-scale=1.0,maximum-scale=1.0">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
<title>会员注册-演示网站</title>
<meta http-equiv="Content-Language" content="zh-CN">
<link rel="stylesheet" rev="stylesheet"
	href="${pageContext.request.contextPath}/static/css/iconfont.css"
	type="text/css" media="all">
<link rel="stylesheet" rev="stylesheet"
	href="${pageContext.request.contextPath}/static/css/login.css"
	type="text/css" media="all">
<style>
body {
	color: #;
}

a {
	color: #;
}

a:hover {
	color: #;
}

.bg-black {
	background-color: #;
}

.tx-login-bg {
	background: url(${pageContext.request.contextPath}/static/images/bg.jpg)
		no-repeat 0 0;
}
</style>
</head>
<body class="tx-login-bg">
	<div class="tx-login-box">
		<div class="login-avatar bg-black">
			<i class="iconfont icon-wode"></i>
		</div>
		<ul class="tx-form-li row">
		<li class="col-24 col-m-24"><p>
					<input type="password" id="name" placeholder="注册用户"
						class="tx-input">
				</p></li>
			<li class="col-24 col-m-24"><p>
					<input type="text" id="username" placeholder="注册账号"
						class="tx-input">
				</p></li>
			<li class="col-24 col-m-24"><p>
					<input type="password" id="password" placeholder="注册密码"
						class="tx-input">
				</p></li>
				<li class="col-24 col-m-24"><p>
					<input type="password" id="rid" placeholder="注册rid"
						class="tx-input">
				</p></li>
			<li class="col-24 col-m-24"><p class="tx-input-full">
					<button id="login" class="tx-btn tx-btn-big bg-black">注册</button>
				</p></li>
		</ul>
	</div>
	<script>
		layui.use([ 'layer', 'jqurey' ], function() {
			var layer = layui.layer, $ = layui.jqurey;

			$("#login").click(function() {
			$.ajax({
			url:'${pageContext.request.contextPath}/user.action?methodName=login',
			dataType:'json',
			data:{
				name:$("#name").val(),
				loginName:$("#username").val(),
				password:$("#password").val(),
				rid:$("#rid").val()
			},
			method:'post',
			sucess:function (data){
				if (data) {
					layer.alert('恭喜'+data.name+'注册成功',{icon:6});	
				}else {
					layer.alert('密码错误',{icon:6});
				}
			}
			});	
			
			})
		});
	</script>
</body>
</html>

2.2编写dao

public int add(User  user) throws Exception {
		String sql = "insert  into   t_oa_user values(?,?,?,?,?)";
		return super.executeUpdate(sql, user, new  String[] {"id","name","loginName","pwd","rid"});
	}

3.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/740789.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

FTP服务器使用及配置

vsftp安装配置 环境配置 服务端:CentOS 7.6 vsftpd 客户端:Windows 10 xftp 服务端 yum -y install epel-release.noarchyum -y install vsftpd* pam* db4*systemctl restart vsftpd#修改配置前备份文件 [rootnode1 ~]# cd /etc/vsftpd/ [rootnode1 vsftpd]# ls ftpusers …

Eclipse调整系统字体(亲测)

1. 打开eclipse的菜单栏windows->preferences 2. 选择General->Appearance->colors and fonts 3. 选择字号&#xff0c;Apply&#xff0c;ok 建议选择常规18号&#xff0c;这样对眼睛友好一些&#xff0c;不易太大太小 为了大家更好的学习交流&#xff0c;博主新建了v…

算法训练营第三十五天||860.柠檬水找零 ● 406.根据身高重建队列 ● 452. 用最少数量的箭引爆气球

860.柠檬水找零 这道题自己不看答案能自己做出来 class Solution { public:bool lemonadeChange(vector<int>& bills) {if(bills[0]10 || bills[0]20) return false;int fivenum 0;int tennum 0;int tewentynum 0;for(int i 0;i<bills.size();i){if(bills[…

Hyper-V 虚拟机安装Ubuntu

Hyper-V 是win自带的虚拟机软件&#xff0c; 免费 进入控制面板&#xff0c;启用功能 勾选Hyper-V 然后重启电脑 打开 Hyper-v快速创建 此处可能需要 science surf network&#xff0c;否则创建虚拟机按钮为灰色 选择合适的版本&#xff0c;点击右下角的创建虚拟机进行安装&a…

【云时代数据利器】奥威BI SaaS版:一键链接云星空,套用百张报表

SaaS模式可以有效加快部署、提高效率、降低成本、提高灵活性&#xff0c;因此广受欢迎。随着市场的需求以及SaaS模式的广为人知&#xff0c;SaaS BI正逐渐成为BI的未来趋势之一&#xff0c;正逐渐成为云时代数据分析利器。奥威BI SaaS版和金蝶云星空标准方案强强联合&#xff0…

C++学习 结构体

目录 结构体 结构体定义和使用 结构体数组 结构体指针 结构体嵌套结构体 结构体做函数的参数 结构体中const使用场景 结构体 结构体定义和使用 定义&#xff1a; 结构体属于用户自定义的数据类型&#xff0c;允许用户存储不同的数据类型。 语法&#xff1a; struct 结构体…

day4 qtqtqtc++

cppcpp ui代码 <?xml version"1.0" encoding"UTF-8"?> <ui version"4.0"><class>Widget</class><widget class"QWidget" name"Widget"><property name"geometry"><rec…

Linux--获取与杀死当前进程PID

获取当前进程的代码&#xff1a; #include <sys/types.h>pid_t idgetpid();//获取的是自己的进程PID 杀死当前进程的指令&#xff1a; kill -9 进程的PID 我要是kill -9 16865(-bash进程)&#xff0c;你会发现无论你输入clear、ls、还是vim...指令&#xff0c;都无…

云深处绝影四足机器人协议学习解析

绝影四足机器人通信协议学习解析 本学习文档介绍了云深处 绝影X20 四足机器人的通信协议&#xff0c;并对相关的通信机制和命令格式进行了简单的解析。该协议在机器人系统和上位机&#xff08;例如外部板卡或系统&#xff09;之间进行TCP通信时使用。 1. 协议端口号 在此协议…

定义一个派生自D1的D2类,并且在D2中覆盖pvf();建立一个D2类的对象并且调用f()、vf()、pvf()

运行代码&#xff1a; //定义一个派生自D1的D2类&#xff0c;并且在D2中覆盖pvf() //建立一个D2类的对象并且调用f()、vf()、pvf() #include"std_lib_facilities.h" //---------------------------------------------------------------------- //定义B1类。 class …

配置通过域名访问网站(NETBASE第七课)

1 DNS服务器 域名系统_百度百科 域名和与之相对应的IP地址转换的服务器 DNS&#xff08;Domain Name Server&#xff0c;域名服务器&#xff09;是进行域名(domain name)和与之相对应的IP地址 (IP address)转换的服务器。DNS中保存了一张域名(domain name)和与之相对应的IP地…

通过GitHub Desktop,将本地项目上传到gitee上

介绍 这里主要介绍&#xff0c;通过 gitHub Desktop 软件&#xff0c;将本地的项目&#xff0c;上传到 gitee的仓库里&#xff08;这里仓库为新建的仓库&#xff0c;什么东西都没有&#xff09;。 这里主要介绍&#xff0c;仓库的新建方式&#xff0c;及本地代码上传到远端的操…

Unity 实现一个揭面膜效果

源码 using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;

【Django】列表页面的搜索功能

目的 页面列表增加多字段搜索显示查询结果 方案 分页显示搜索结果 效果 实现 列表页面 # list.html <div class"pull-left" style"margin-bottom: 10px"><form action"{% url api-search %}" method"get"><div …

ModaHub魔搭社区:开源向量数据库的Milvus怎么读?

Milvus是一个中文词语,意为“Milvus navigate,为智慧找方向,为价值做链接,为创作者做伙伴”。在读这个词语时,可以按照以下方式发音: 首先,我们需要将Milvus这个词语分解成多个音节。根据汉语拼音的规则,可以将其分解为“mi”、“lu”、“su”。 接下来,我们需要根…

Java阶段五Day03

Java阶段五Day03 文章目录 Java阶段五Day03回顾git命令Git远程仓库远程仓库概念远程仓库分支操作分支管理策略 回顾git命令 本地版本控制 git initgit addgit commitgit loggit statusgit taggit refloggit reset 分支管理 git branchgit branch b1git checkout b1git merg…

C#核心知识回顾——13.多线程、预处理器指令

1.多线程 了解线程前先了解进程 进程&#xff08;Process&#xff09;是计算机中的程序关于某数据集合上的一次运行活动 是系统进行资源分配和调度的基本单位&#xff0c;是操作系统结构的基础 说人话&#xff1a;打开个应用程序就是在慢作系统上开启了一个进程 进程之间可以相…

【Vscode】解决 An SSH installation couldn‘t be found

【Vscode】解决 An SSH installation couldn‘t be found 背景描述&#xff1a;在vscode中使用ssh进行连接到时候&#xff0c;已经安装了ssh romote的plugin插件&#xff0c;但是在输入了ssh连接命令之后&#xff0c;仍然出现报错&#xff1a;an ssh installation could not be…

vue3+mapboxgl鼠标浮动显示cgcs2000

一、需求 鼠标在地图中浮动展示地图的经纬度&#xff0c;cgcs2000 xy 还有显示带号 二、实现效果 展示经度&#xff0c;纬度&#xff0c;x值&#xff0c;y值显示的是带号和y值 三、思路 3.1、mapbox获取经纬度方法 初始化地图后.on方法中有个mousemove方法 mapboxUtil._m…

leetcode:递增的三元子序列

递增的三元子序列 题解部分转自leetcode:Xzz medium 给你一个整数数组 nums &#xff0c;判断这个数组中是否存在长度为 3 的递增子序列。 如果存在这样的三元组下标 (i, j, k) 且满足 i < j < k &#xff0c;使得 nums[i] < nums[j] < nums[k] &#xff0c;返回…