layui数据表格的
3 种方式
方法渲染
<table id="demo2"></table>
table.render({
elem:"#demo2",// elem 属性用来绑定容器的 id 属性值
url:"js/province.json",// 数据接口
height:315,
page:true,
cols:[[
{field:'code',title:'code',sort:true,width:100},
{field:'name',title:'name',width:200}
]],
});
自动渲染
1) 带有 class="layui-table" 的 <table> 标签。
2) 对标签设置属性 lay-data="" 用于配置一些基础参数
3) 在 <th> 标签中设置属性lay-data=""用于配置表头信息
<table class="layui-table" lay-data="{height:315, url:'js/province.json', page:true}" lay-filter="test">
<thead>
<tr>
<th lay-data="{field:'code', width:80, sort: true}">ID</th>
<th lay-data=