这几天使用LayUI + PHP + MS SQL Server写一个小程序,开发工具使用的是HBuilder,就是把先前使用Powerbuilder完成的C/S程序转换成Web程序。
第一次完整地写,有一点不习惯这样的开发方式,不过好在基本上都找到了解决办法,这里记录和更新开发过程中使用到的一些资料,方便后面的查找使用。
LayUI停止了更新,后面写程序可能使用LayUI就不多了,它还是有很多有点,使用它对付一些中小型程序还是挺好的。
1、LayUI初始化
//-----------------------LayUI初始化
layui.use(['form', 'table'], function () {
var $ = layui.jquery,
form = layui.form,
element=layui.element,
table = layui.table;
))
使用前必须初始化,使用哪个组件就注册哪个组件。
2、赋值与取值
//body的放置
添加
批量删除
关闭
编辑
删除
//操作
table.render({
elem: '#currentTableId',
url: 'ZTBUserList.php',
toolbar: '#toolbarDemo',
defaultToolbar: ['exports'],
cols: [[
{type: "checkbox", width: 40},
{field: 'c01', width: 60, title: '数据库ID', sort: true},
{field: 'c02', width: 100, title: '用户名'},
{field: 'c03', width: 100, title: '密码'},
{field: 'c04', width: 100, title: '类型'},
{field: 'c05', width: 100, title: '单位名'},
{field: 'c06', width: 80, title: '编码'},
{field: 'c07', width: 100, title: '岗位'},
{field: 'c08', width: 100, title: '邮件帐号'},
{title: '操作',width: 120, toolbar: '#currentTableBar', align: "center"}
]],
limits: [5,10],
limit: 10,
page: true,
skin: 'line'
});
// toolbar监听事件
table.on('toolbar(currentTableFilter)', function (obj) {
if (obj.event === 'add') { // 监听添加操作
var index = layer.open({
title: '添加用户',
type: 2,
shade: 0.2,
maxmin:false,
shadeClose: true,
area: ['100%', '100%'],
content: 'ZTBUserAdd.html',
});
$(window).on("resize", function () {
layer.full(index);
});
} else if (obj.event === 'delete') { // 监听批量删除操作
var checkStatus = table.checkStatus('currentTableId')
, data = checkStatus.data;
// layer.alert(JSON.stringify(data));
// console.log(JSON.stringify(data));
for(var i=0;i
关注
打赏
最近更新
- 深拷贝和浅拷贝的区别(重点)
- 【Vue】走进Vue框架世界
- 【云服务器】项目部署—搭建网站—vue电商后台管理系统
- 【React介绍】 一文带你深入React
- 【React】React组件实例的三大属性之state,props,refs(你学废了吗)
- 【脚手架VueCLI】从零开始,创建一个VUE项目
- 【React】深入理解React组件生命周期----图文详解(含代码)
- 【React】DOM的Diffing算法是什么?以及DOM中key的作用----经典面试题
- 【React】1_使用React脚手架创建项目步骤--------详解(含项目结构说明)
- 【React】2_如何使用react脚手架写一个简单的页面?