Use layui timeline process record:
layui official website timeline introduction is relatively small, it may be too simple, here the timeline is requested through the background data. Then automatically fill in the corresponding block and encapsulate it;
The code is as follows:
function timelineshow(url,json,div){ $.ajax({ url: url, type: "post", data: json, dataType: "json", success: function (res) { console.log(res); if(res.SUCCESS===true){ var list = res.data; var uls = "<ul class=\"layui-timeline\">"; var uls1 = "<ul>"; var uls2 = "</ul>"; var lis = "<li class=\"layui-timeline-item\">"; var lis1 = "<li>"; var lis2 = "</li>"; var is = "<i class=\"layui-icon layui-timeline-axis\"></i>"; var divs = "<div class=\"layui-timeline-content layui-text\">"; var divs2 = "</div>"; var h3s = "<h3 class=\"layui-timeline-title\">"; var h3s2 = "</h3>"; var ps = "<p>"; var ps2 = "</p>"; var br = "</br>"; if(list.length>0){ var content1 = ""; content1 = content1+uls; for(var i=0; i<list.length; i++){ var content2 = ""; content2 = content2+lis+is+divs; if(list[i].time!=null&&list[i].time!=''){ content2 = content2+h3s+createTime(list[i].time)+h3s2 } if(list[i].content!=null&&list[i].content!=''){ content2 = content2+ps+list[i].content+ps2; } if(list[i].ul!=null&&list[i].ul.length>0){ var list2 = list[i].ul; content2 = content2+uls1; for(var j=0; j<list2.length; j++){ if(list2[j].content!=null&&list2[j].content!=''){ content2 = content2+lis1+list2[j].content+lis2; } } content2 = content2+uls2; } //可扩展 content2 = content2 + divs2+lis2; content1 =content1+content2; } content1 = content1 +uls2; //再跟你想追加的代码加到一起插入div中 document.getElementById(div).innerHTML = content1; } }else if(res.SUCCESS===false){ layer.msg(res.msg); } } }); } function createTime(v){ var date = new Date(v); var y = date.getFullYear(); var m = date.getMonth()+1; m = m<10?'0'+m:m; var d = date.getDate(); d = d<10?("0"+d):d; var h = date.getHours(); h = h<10?("0"+h):h; var ms = date.getMinutes(); ms = ms<10?("0"+ms):ms; var s = date.getSeconds(); s = s<10?("0"+s):s; var str = y+"-"+m+"-"+d+" "+h+":"+ms+":"+s; return str; }
The call is as follows:
var url = "./json/timeline/dome1.js";<br>var json = {}; <br>timelineshow(url,json,"div1");//url为请求数据地址;json为参数json字符串;打三个参数为时间线显示位置标签id
Parameter description:
url: actual Background request address;
json: request parameters;
The third parameter: timeline drawing point
Data response form:
{ "SUCCESS": true, "data": [{ "time": "2019-01-04 11:00:42", "content":"这是一条测试内容", "ul":[{ "content":"子内容1" }, { "content":"子内容1" }] }, { "time": 1546571007000, "content":"这是一条测试内容", "ul":[{ "content":"子内容1" }, { "content":"子内容1" }] }, { "time": 1546571096000, "content":"这是一条测试内容" }, { "time": 1546571118000, "content":"这是一条测试内容" }, { "time": 1546571159000, "content":"这是一条测试内容" }, { "time": 1546571372000, "content":"这是一条测试内容" }, { "time": 1546571458000, "content":"这是一条测试内容" }, { "time": 1546571721000, "content":"这是一条测试内容" }, { "time": 1546572137000, "content":"这是一条测试内容" }], "msg": "查询成功!" }
Parameter description:
"SUCCESS": calling interface status feedback;
"data": timeline content
"time": timeline time; timestamp format can be passed here; You can also pass in a defined time format; such as: "2019-01-04 11:00:42"
"content":content
"url":sub-content
"content": content part
"msg": call interface feedback information; when "SUCCESS" is false, prompt information will be based on this field
Effect display:
For more layui knowledge, please pay attention to the layui usage tutorial column.
The above is the detailed content of layui timeline usage example. For more information, please follow other related articles on the PHP Chinese website!

The article discusses using Layui's flow module for infinite scrolling, covering setup, best practices, performance optimization, and customization for enhanced user experience.

The article details how to use Layui's element module to create and customize UI elements like tabs, accordions, and progress bars, highlighting HTML structures, initialization, and common pitfalls to avoid.Character count: 159

The article discusses customizing Layui's carousel module, focusing on CSS and JavaScript modifications for appearance and behavior, including transition effects, autoplay settings, and adding custom navigation controls.

The article guides on using Layui's carousel module for image sliders, detailing steps for setup, customization options, implementing autoplay and navigation, and performance optimization strategies.

The article discusses configuring Layui's upload module to restrict file types and sizes using accept, exts, and size properties, and customizing error messages for violations.

The article explains how to use Layui's layer module to create modal windows and dialog boxes, detailing setup, types, customization, and common pitfalls to avoid.

Layui, known for simplicity and performance, is compared with Bootstrap and Semantic UI on design, components, and integration ease. Layui excels in modularity and Chinese support.(159 characters)

Layui extends beyond basic web apps to SPAs, real-time dashboards, PWAs, and complex data visualization, enhancing enterprise-level user experiences with its modular design and rich UI components.(159 characters)


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Chinese version
Chinese version, very easy to use