demo1.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <title>功能演示1 - 通用分页组件</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. </div>
  8. </div>
  9. <div class="layui-fluid">
  10. <div class="layui-row layui-col-space15">
  11. <div class="layui-col-md12">
  12. <div class="layui-card">
  13. <div class="layui-card-header">总页数低于页码总数</div>
  14. <div class="layui-card-body">
  15. <div id="test-laypage-demo0"></div>
  16. </div>
  17. </div>
  18. </div>
  19. <div class="layui-col-md12">
  20. <div class="layui-card">
  21. <div class="layui-card-header">总页数大于页码总数</div>
  22. <div class="layui-card-body">
  23. <div id="test-laypage-demo1"></div>
  24. </div>
  25. </div>
  26. </div>
  27. <div class="layui-col-md12">
  28. <div class="layui-card">
  29. <div class="layui-card-header">自定义主题 - 颜色随意定义</div>
  30. <div class="layui-card-body">
  31. <div id="test-laypage-demo2"></div>
  32. <div id="test-laypage-demo2-1"></div>
  33. <div id="test-laypage-demo2-2"></div>
  34. </div>
  35. </div>
  36. </div>
  37. <div class="layui-col-md12">
  38. <div class="layui-card">
  39. <div class="layui-card-header">自定义首页、尾页、上一页、下一页文本</div>
  40. <div class="layui-card-body">
  41. <div id="test-laypage-demo3"></div>
  42. </div>
  43. </div>
  44. </div>
  45. <div class="layui-col-md12">
  46. <div class="layui-card">
  47. <div class="layui-card-header">不显示首页尾页</div>
  48. <div class="layui-card-body">
  49. <div id="test-laypage-demo4"></div>
  50. </div>
  51. </div>
  52. </div>
  53. <div class="layui-col-md12">
  54. <div class="layui-card">
  55. <div class="layui-card-header">开启HASH</div>
  56. <div class="layui-card-body">
  57. <div id="test-laypage-demo5"></div>
  58. </div>
  59. </div>
  60. </div>
  61. <div class="layui-col-md12">
  62. <div class="layui-card">
  63. <div class="layui-card-header">只显示上一页、下一页</div>
  64. <div class="layui-card-body">
  65. <div id="test-laypage-demo6"></div>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. <script>
  72. layui.use(['admin', 'laypage'], function(){
  73. var laypage = layui.laypage;
  74. //总页数低于页码总数
  75. laypage.render({
  76. elem: 'test-laypage-demo0'
  77. ,count: 50 //数据总数
  78. });
  79. //总页数大于页码总数
  80. laypage.render({
  81. elem: 'test-laypage-demo1'
  82. ,count: 70 //数据总数
  83. ,jump: function(obj){
  84. console.log(obj)
  85. }
  86. });
  87. //自定义样式
  88. laypage.render({
  89. elem: 'test-laypage-demo2'
  90. ,count: 100
  91. ,theme: '#1E9FFF'
  92. });
  93. laypage.render({
  94. elem: 'test-laypage-demo2-1'
  95. ,count: 100
  96. ,theme: '#FF5722'
  97. });
  98. laypage.render({
  99. elem: 'test-laypage-demo2-2'
  100. ,count: 100
  101. ,theme: '#FFB800'
  102. });
  103. //自定义首页、尾页、上一页、下一页文本
  104. laypage.render({
  105. elem: 'test-laypage-demo3'
  106. ,count: 100
  107. ,first: '首页'
  108. ,last: '尾页'
  109. ,prev: '<em>←</em>'
  110. ,next: '<em>→</em>'
  111. });
  112. //不显示首页尾页
  113. laypage.render({
  114. elem: 'test-laypage-demo4'
  115. ,count: 100
  116. ,first: false
  117. ,last: false
  118. });
  119. //开启HASH
  120. laypage.render({
  121. elem: 'test-laypage-demo5'
  122. ,count: 500
  123. ,curr: location.hash.replace('#!fenye=', '') //获取hash值为fenye的当前页
  124. ,hash: 'fenye' //自定义hash值
  125. });
  126. //只显示上一页、下一页
  127. laypage.render({
  128. elem: 'test-laypage-demo6'
  129. ,count: 50
  130. ,layout: ['prev', 'next']
  131. ,jump: function(obj, first){
  132. if(!first){
  133. layer.msg('第 '+ obj.curr +' 页');
  134. }
  135. }
  136. });
  137. });
  138. </script>