simple.html 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <title>简单用法 - 数据表格</title>
  2. <div class="layui-card layadmin-header">
  3. <div class="layui-breadcrumb" lay-filter="breadcrumb">
  4. <a lay-href="">主页</a>
  5. <a><cite>组件</cite></a>
  6. <a><cite>数据表格</cite></a>
  7. <a><cite>简单用法</cite></a>
  8. </div>
  9. </div>
  10. <div class="layui-fluid">
  11. <div class="layui-row layui-col-space15">
  12. <div class="layui-col-md12">
  13. <div class="layui-card">
  14. <div class="layui-card-header">简单用法</div>
  15. <div class="layui-card-body">
  16. <table class="layui-hide" id="test-table-simple"></table>
  17. </div>
  18. </div>
  19. </div>
  20. </div>
  21. </div>
  22. <script>
  23. layui.use(['admin', 'table'], function(){
  24. var table = layui.table;
  25. table.render({
  26. elem: '#test-table-simple'
  27. ,url: './json/table/user.js'
  28. ,cellMinWidth: 80 //全局定义常规单元格的最小宽度,layui 2.2.1 新增
  29. ,cols: [[
  30. {field:'id', width:80, title: 'ID', sort: true}
  31. ,{field:'username', width:80, title: '用户名'}
  32. ,{field:'sex', width:80, title: '性别', sort: true}
  33. ,{field:'city', width:80, title: '城市'}
  34. ,{field:'sign', title: '签名', width: '30%', minWidth: 100} //minWidth:局部定义当前单元格的最小宽度,layui 2.2.1 新增
  35. ,{field:'experience', title: '积分', sort: true}
  36. ,{field:'score', title: '评分', sort: true}
  37. ,{field:'classify', title: '职业'}
  38. ,{field:'wealth', width:137, title: '财富', sort: true}
  39. ]]
  40. });
  41. });
  42. </script>