layui implements display of multiple time styles on the same page
layui implements the code to display multiple time styles on the same page as follows:
<!DOCTYPE html> <html> <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"> <title>layui在线调试</title> <link rel="stylesheet" href="//res.layui.com/layui/dist/css/layui.css?t=1591161919722" media="all"> <style> body{margin: 10px;} .demo-carousel{height: 200px; line-height: 200px; text-align: center;} </style> </head> <body> <table class="layui-hide" id="demo" lay-filter="test"></table> <script type="text/html" id="barDemo"> <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a> <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a> <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a> </script> <div class="layui-tab layui-tab-brief" lay-filter="demo"> <ul class="layui-tab-title"> <li class="layui-this">演示说明</li> <li>日期</li> <li>分页</li> <li>上传</li> <li>滑块</li> </ul> <div class="layui-tab-content"> <div class="layui-tab-item layui-show"> <div class="layui-carousel" id="test1"> <div carousel-item> <div><p class="layui-bg-green demo-carousel">在这里,你将以最直观的形式体验 layui!</p></div> <div><p class="layui-bg-red demo-carousel">在编辑器中可以执行 layui 相关的一切代码</p></div> <div><p class="layui-bg-blue demo-carousel">你也可以点击左侧导航针对性地试验我们提供的示例</p></div> <div><p class="layui-bg-orange demo-carousel">如果最左侧的导航的高度超出了你的屏幕</p></div> <div><p class="layui-bg-cyan demo-carousel">你可以将鼠标移入导航区域,然后滑动鼠标滚轮即可</p></div> </div> </div> </div> <div class="layui-tab-item"> <div id="laydateDemo"></div> </div> <div class="layui-tab-item"> <div id="pageDemo"></div> </div> <div class="layui-tab-item"> <div class="layui-upload-drag" id="uploadDemo"> <i class="layui-icon"></i> <p>点击上传,或将文件拖拽到此处</p> <div class="layui-hide" id="uploadDemoView"> <hr> <img src="" alt="上传成功后渲染" style="max-width: 100%"> </div> </div> </div> <div class="layui-tab-item"> <div id="sliderDemo" style="margin: 50px 20px;"></div> </div> </div> </div> <blockquote class="layui-elem-quote layui-quote-nm layui-hide" id="footer">layui {{ layui.v }} 提供强力驱动</blockquote> <script src="//res.layui.com/layui/dist/layui.js?t=1591161919722"></script> <script> layui.config({ version: '1591161919722' //为了更新 js 缓存,可忽略 }); layui.use(['laydate', 'laypage', 'layer', 'table', 'carousel', 'upload', 'element', 'slider'], function(){ var laydate = layui.laydate //日期 ,laypage = layui.laypage //分页 ,layer = layui.layer //弹层 ,table = layui.table //表格 ,carousel = layui.carousel //轮播 ,upload = layui.upload //上传 ,element = layui.element //元素操作 ,slider = layui.slider //滑块 //向世界问个好 layer.msg('Hello World'); //监听Tab切换 element.on('tab(demo)', function(data){ layer.tips('切换了 '+ data.index +':'+ this.innerHTML, this, { tips: 1 }); }); //执行一个 table 实例 table.render({ elem: '#demo' ,height: 420 ,url: '/demo/table/user/' //数据接口 ,title: '用户表' ,page: true //开启分页 ,toolbar: 'default' //开启工具栏,此处显示默认图标,可以自定义模板,详见文档 ,totalRow: true //开启合计行 ,cols: [[ //表头 {type: 'checkbox', fixed: 'left'} ,{field: 'id', title: 'ID', width:80, sort: true, fixed: 'left', totalRowText: '合计:'} ,{field: 'username', title: '用户名', width:80} ,{field: 'experience', title: '积分', width: 90, sort: true, totalRow: true} ,{field: 'sex', title: '性别', width:80, sort: true} ,{field: 'score', title: '评分', width: 80, sort: true, totalRow: true} ,{field: 'city', title: '城市', width:150} ,{field: 'sign', title: '签名', width: 200} ,{field: 'classify', title: '职业', width: 100} ,{field: 'wealth', title: '财富', width: 135, sort: true, totalRow: true} ,{fixed: 'right', width: 165, align:'center', toolbar: '#barDemo'} ]] }); //监听头工具栏事件 table.on('toolbar(test)', function(obj){ var checkStatus = table.checkStatus(obj.config.id) ,data = checkStatus.data; //获取选中的数据 switch(obj.event){ case 'add': layer.msg('添加'); break; case 'update': if(data.length === 0){ layer.msg('请选择一行'); } else if(data.length > 1){ layer.msg('只能同时编辑一个'); } else { layer.alert('编辑 [id]:'+ checkStatus.data[0].id); } break; case 'delete': if(data.length === 0){ layer.msg('请选择一行'); } else { layer.msg('删除'); } break; }; }); //监听行工具事件 table.on('tool(test)', function(obj){ //注:tool 是工具条事件名,test 是 table 原始容器的属性 lay-filter="对应的值" var data = obj.data //获得当前行数据 ,layEvent = obj.event; //获得 lay-event 对应的值 if(layEvent === 'detail'){ layer.msg('查看操作'); } else if(layEvent === 'del'){ layer.confirm('真的删除行么', function(index){ obj.del(); //删除对应行(tr)的DOM结构 layer.close(index); //向服务端发送删除指令 }); } else if(layEvent === 'edit'){ layer.msg('编辑操作'); } }); //执行一个轮播实例 carousel.render({ elem: '#test1' ,width: '100%' //设置容器宽度 ,height: 200 ,arrow: 'none' //不显示箭头 ,anim: 'fade' //切换动画方式 }); //将日期直接嵌套在指定容器中 var dateIns = laydate.render({ elem: '#laydateDemo' ,position: 'static' ,calendar: true //是否开启公历重要节日 ,mark: { //标记重要日子 '0-10-14': '生日' ,'2020-01-18': '小年' ,'2020-01-24': '除夕' ,'2020-01-25': '春节' ,'2020-02-01': '上班' } ,done: function(value, date, endDate){ if(date.year == 2017 && date.month == 11 && date.date == 30){ dateIns.hint('一不小心就月底了呢'); } } ,change: function(value, date, endDate){ layer.msg(value) } }); //分页 laypage.render({ elem: 'pageDemo' //分页容器的id ,count: 100 //总页数 ,skin: '#1E9FFF' //自定义选中色值 //,skip: true //开启跳页 ,jump: function(obj, first){ if(!first){ layer.msg('第'+ obj.curr +'页', {offset: 'b'}); } } }); //上传 upload.render({ elem: '#uploadDemo' ,url: 'https://httpbin.org/post' //改成您自己的上传接口 ,done: function(res){ layer.msg('上传成功'); layui.$('#uploadDemoView').removeClass('layui-hide').find('img').attr('src', res.files.file); console.log(res) } }); //滑块 var sliderInst = slider.render({ elem: '#sliderDemo' ,input: true //输入框 }); //底部信息 var footerTpl = lay('#footer')[0].innerHTML; lay('#footer').html(layui.laytpl(footerTpl).render({})) .removeClass('layui-hide'); }); </script> </body> </html>
The effect is as follows:
MorelayuiFor knowledge, please pay attention to the layui tutorial column of the PHP Chinese website
The above is the detailed content of layui implements display of multiple time styles on the same page. 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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics



Layui login page jump setting steps: Add jump code: Add judgment in the login form submit button click event, and jump to the specified page through window.location.href after successful login. Modify the form configuration: add a hidden input field to the form element of lay-filter="login", with the name "redirect" and the value being the target page address.

layui provides a variety of methods for obtaining form data, including directly obtaining all field data of the form, obtaining the value of a single form element, using the formAPI.getVal() method to obtain the specified field value, serializing the form data and using it as an AJAX request parameter, and listening Form submission event gets data.

Adaptive layout can be achieved by using the responsive layout function of the layui framework. The steps include: referencing the layui framework. Define an adaptive layout container and set the layui-container class. Use responsive breakpoints (xs/sm/md/lg) to hide elements under specific breakpoints. Specify element width using the grid system (layui-col-). Create spacing via offset (layui-offset-). Use responsive utilities (layui-invisible/show/block/inline) to control the visibility of elements and how they appear.

The method of using layui to transmit data is as follows: Use Ajax: Create the request object, set the request parameters (URL, method, data), and process the response. Use built-in methods: Simplify data transfer using built-in methods such as $.post, $.get, $.postJSON, or $.getJSON.

The difference between layui and Vue is mainly reflected in functions and concerns. Layui focuses on rapid development of UI elements and provides prefabricated components to simplify page construction; Vue is a full-stack framework that focuses on data binding, component development and state management, and is more suitable for building complex applications. Layui is easy to learn and suitable for quickly building pages; Vue has a steep learning curve but helps build scalable and easy-to-maintain applications. Depending on the project needs and developer skill level, the appropriate framework can be selected.

The layui framework is a JavaScript-based front-end framework that provides a set of easy-to-use UI components and tools to help developers quickly build responsive web applications. Its features include: modular, lightweight, responsive, and has complete documentation and community support. layui is widely used in the development of management backend systems, e-commerce websites, and mobile applications. The advantages are quick start-up, improved efficiency, and easy maintenance. The disadvantages are poor customization and slow technology updates.

layui is a front-end UI framework that provides a wealth of UI components, tools and functions to help developers quickly build modern, responsive and interactive web applications. Its features include: flexible and lightweight, modular design, rich components, Powerful tools and easy customization. It is widely used in the development of various web applications, including management systems, e-commerce platforms, content management systems, social networks and mobile applications.

To run layui, perform the following steps: 1. Import layui script; 2. Initialize layui; 3. Use layui components; 4. Import layui styles (optional); 5. Ensure script compatibility and pay attention to other considerations. With these steps, you can build web applications using the power of layui.
