layui table源码修改(1、loading;2、error)

版本layui-v2.2.6
  • 1、layui table首次加载没有显示loading的加载动画
    方法:在lay > modules 下的 table.js 文件中的下面位置添加js代码
if(n.url&&n.loading){i=i||a.loading();}

添加高亮的代码

  • 2、请求错误时,执行错误的回调函数
    方法:在lay > modules 下的 table.js 文件中的下面位置添加js代码
n.error && n.error(e);

其中 error与done是同一个对象的属性(图中高亮处)

在这里插入图片描述

根据提供的引用内容,我们可以知道Layui是一个模块化的前端UI框架,其中包括了table模块。如果想要开发Layui table模块的源码,可以按照以下步骤进行: 1. 首先,在HTML页面中引入Layui的相关文件,包括layui.js和layui.css。 2. 在HTML页面中添加一个table元素,并为其添加一个id属性,例如: ```html <table id="demo"></table> ``` 3. 在JavaScript文件中,使用Layuitable模块进行表格的渲染和数据的加载,例如: ```javascript layui.use('table', function(){ var table = layui.table; // 渲染表格 table.render({ elem: '#demo', // 指定表格元素 url: '/demo/table/user/', // 数据接口 page: true, // 开启分页 cols: [[ // 表头 {field: 'id', title: 'ID', width: 80}, {field: 'username', title: '用户名', width: 120}, {field: 'sex', title: '性别', width: 80, sort: true}, {field: 'city', title: '城市', width: 100}, {field: 'sign', title: '签名', width: 200}, {field: 'experience', title: '积分', width: 80, sort: true}, {field: 'score', title: '评分', width: 80, sort: true}, {field: 'classify', title: '职业', width: 100}, {field: 'wealth', title: '财富', width: 150, sort: true} ]] }); }); ``` 在上述代码中,我们使用了Layuitable.render()方法来渲染表格,其中elem属性指定了表格元素的id,url属性指定了数据接口的地址,page属性开启了分页功能,cols属性指定了表头和每一列的字段名。 4. 在后端编写数据接口,返回符合Layui table模块要求的JSON格式的数据。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值