layUi数据表格自动渲染

https://www.layui.com/doc/modules/table.html#autoRender

<table class="layui-table" lay-data="{height:315, url:'/demo/table/user/', page:true, id:'test'}" lay-filter="test">
  <thead>
    <tr>
      <th lay-data="{field:'id', width:80, sort: true}">ID</th>
      <th lay-data="{field:'username', width:80}">用户名</th>
      <th lay-data="{field:'sex', width:80, sort: true}">性别</th>
      <th lay-data="{field:'city'}">城市</th>
      <th lay-data="{field:'sign'}">签名</th>
      <th lay-data="{field:'experience', sort: true}">积分</th>
      <th lay-data="{field:'score', sort: true}">评分</th>
      <th lay-data="{field:'classify'}">职业</th>
      <th lay-data="{field:'wealth', sort: true}">财富</th>
    </tr>
  </thead>
</table>
    

自动渲染,直接在表格中配置好参数信息,无需再去写js,也可直接在此处开启分页 layui默认有分页设置,只需在lay-data的参数中写 page:true即可开启分页。

猜你喜欢

转载自www.cnblogs.com/lxk233/p/9860969.html