


Introduction to different reference methods of layui modularization and non-modularization
The different reference methods of layui modular and non-modular:
1. The difference between modular and non-modular
There are many different built-in modules in layui, such as pop-up layers, date and time pickers, paging and other different modules.
Modularization: Load the corresponding module when using it.
Non-modular: Load all modules at once.
2. Modular reference
Reference ../layui/layui.js
① Usually write a tool class layui.util.js (Extensible), directly reference
var layer;var laydate; layui.use(['layer','laydate'], function() { layer = layui.layer; laydate = layui.laydate; });
in the jsp page ② jsp page
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Insert title here</title> <script type="text/javascript" src="js/layui/layui.all.js"></script> <script type="text/javascript" src="js/jquery-1.11.1.min.js"></script> <script type="text/javascript" src="js/layui/layui_util.js"></script> <script type="text/javascript"> $(function(){ laydate.render({ elem: '#test' //指定元素 }); }); function openLayui() { layer.msg('hello'); layer.open({ type : 1, maxmin : true, area: ['500px', '300px'], content : $('#inputId'), btn: ['确定', '重置', '关闭'], //可以无限个按钮, btn1: function(index, layero){ alert(parent.$("#inputId").val()); //layer.close(parent.layer.getFrameIndex(window.name)); layer.close(index); }, btn2: function(index, layero){ layer.style(index, { width: '80px' }); parent.$("#inputId").val("button"); return false; }, btn3: function(index, layero){ alert(index); return false; } }); var index = layer.getFrameIndex(window.name); layer.title('傻逼', index); } </script> </head> <body> <input type="button" onclick="openLayui()" id="inputId" value="弹框" /> <input type="text" id="test"/> </body> </html>
3, non-modular reference
Reference .. /layui/layui.all.js
Usually write a tool class layui.util.js (extensible), directly reference layer, laydate....
var layer = layui.layer; var laydate = layui.laydate;
or directly on the jsp page You can use layui.layer and layui.laydate on jsp pages.
For more layui knowledge, please pay attention to the layui usage tutorial column on the PHP Chinese website.
The above is the detailed content of Introduction to different reference methods of layui modularization and non-modularization. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools