html代码
<table class="layui-table" id="table_user" lay-filter="table_user"> </table>
js代码
layui.use('table', function(){
var table = layui.table;
table.render({
elem: '[lay-filter="table_user"]',
height: 300,
url:'index.php',
type: 'GET',
cols:[[{ field: 'name', title: '名称' },
{ field: 'industry', title: '行业' },
{ field: 'status', title: '状态' },
{ field: 'num', title: '数量' },
{ field: 'price', title: '单价' }
]],
//解析服务器端返回的数据
parseData: function (res) {
/*if (res.code == 500) {
return false
}*/
return {
"code":0,
"msg":"",
"count": 1000,
"data": res.result
};
},
});
});
本文介绍了一个使用layui框架实现的表格组件示例,通过HTML和JS代码展示了如何配置和渲染一个包含名称、行业、状态等字段的表格,并对服务器返回的数据进行了解析。

9830

被折叠的 条评论
为什么被折叠?



