laypage.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>镜像站@layPage, 多功能JS分页组件/插件 - 在线演示 - Layui</title>
  6. <meta name="renderer" content="webkit">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  8. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  9. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  10. <meta name="apple-mobile-web-app-capable" content="yes">
  11. <meta name="format-detection" content="telephone=no">
  12. <script>
  13. ;!function(){self!==parent&&(location.href="http://www.baidu.com/")}();
  14. </script>
  15. <link rel="stylesheet" href="/public/layui/dist/css/layui.css" tppabs="http://res.layui.com/layui/dist/css/layui.css?t=1632428048355" media="all">
  16. <link rel="stylesheet" href="/public/static/css/global.css" tppabs="http://res.layui.com/static/css/global.css?t=1632428048355-19" media="all">
  17. </head>
  18. <body>
  19. <div class="layui-layout layui-layout-admin">
  20. <div class="layui-header header header-demo" autumn>
  21. <div class="layui-fluid">
  22. <a class="logo" href="../index.html" tppabs="http://www.layui.com/">
  23. <img src="/public/static/images/layui/logo.png" tppabs="http://res.layui.com/static/images/layui/logo.png" alt="layui">
  24. </a>
  25. <div class="layui-form layui-hide-xs component" lay-filter="LAY-site-header-component"></div>
  26. <div class="layui-hide-xs site-notice"></div>
  27. <ul class="layui-nav" id="LAY_NAV_TOP">
  28. <li class="layui-nav-item ">
  29. <a href="../doc/index.html" tppabs="http://www.layui.com/doc/">文档</a>
  30. </li>
  31. <li class="layui-nav-item layui-this">
  32. <a href="index.html" tppabs="http://www.layui.com/demo/">示例</a>
  33. </li>
  34. <li class="layui-nav-item">
  35. <a href="javascript:;">
  36. <!--<span class="layui-badge-dot" style="left:0; right: auto; margin: -4px 0 0 5px;"></span>-->
  37. 周边
  38. </a>
  39. <dl class="layui-nav-child layui-nav-child-c">
  40. <dd class="layui-hide-sm layui-show-xs" lay-unselect>
  41. <a href="https://gitee.com/sentsin/layui/issues" target="_blank" rel="nofollow">问题反馈</a>
  42. <hr>
  43. </dd>
  44. <dd lay-unselect><a href="../alone.html" tppabs="http://www.layui.com/alone.html" target="_blank" lay-unselect>独立组件</a></dd>
  45. <dd lay-unselect><a href="../../fly.layui.com/extend/index.html" target="_blank">扩展组件</a></dd>
  46. </dl>
  47. </li>
  48. <li class="layui-nav-item layui-hide-xs">
  49. <a href="http://gitee.com/sentsin/layui/issues" target="_blank" rel="nofollow">反馈</a>
  50. </li>
  51. </ul>
  52. </div>
  53. </div>
  54. <!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
  55. <!--[if lt IE 9]>
  56. <script src="../../other/html5shiv/r29/html5.min.js" tppabs="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  57. <script src="../../other/respond.js/1.4.2/respond.min.js" tppabs="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
  58. <![endif]-->
  59. <div class="layui-side layui-bg-black">
  60. <div class="layui-side-scroll">
  61. <ul class="layui-nav layui-nav-tree site-demo-nav">
  62. <li class="layui-nav-item layui-nav-itemed">
  63. <a class="javascript:;" href="javascript:;">演示</a>
  64. <dl class="layui-nav-child">
  65. <dd>
  66. <a href="index.html" tppabs="http://www.layui.com/demo/">调试预览</a>
  67. </dd>
  68. </dl>
  69. </li>
  70. <li class="layui-nav-item layui-nav-itemed">
  71. <a class="javascript:;" href="javascript:;">布局</a>
  72. <dl class="layui-nav-child">
  73. <dd class="">
  74. <a href="grid.html" tppabs="http://www.layui.com/demo/grid.html">栅格</a>
  75. </dd>
  76. <dd class="">
  77. <a href="admin.html" tppabs="http://www.layui.com/demo/admin.html">框架</a>
  78. </dd>
  79. </dl>
  80. </li>
  81. <li class="layui-nav-item layui-nav-itemed">
  82. <a class="javascript:;" href="javascript:;">基本元素</a>
  83. <dl class="layui-nav-child">
  84. <dd class="">
  85. <a href="button.html" tppabs="http://www.layui.com/demo/button.html">按钮</a>
  86. </dd>
  87. <dd class="">
  88. <a href="form.html" tppabs="http://www.layui.com/demo/form.html">表单</a>
  89. </dd>
  90. <dd class="">
  91. <a href="nav.html" tppabs="http://www.layui.com/demo/nav.html">导航 / 面包屑</a>
  92. </dd>
  93. <dd class="">
  94. <a href="menu.html" tppabs="http://www.layui.com/demo/menu.html">基础菜单</a>
  95. </dd>
  96. <dd class="">
  97. <a href="tab.html" tppabs="http://www.layui.com/demo/tab.html">选项卡</a>
  98. </dd>
  99. <dd class="">
  100. <a href="progress.html" tppabs="http://www.layui.com/demo/progress.html">进度条</a>
  101. </dd>
  102. <dd class="">
  103. <a href="panel.html" tppabs="http://www.layui.com/demo/panel.html">面板</a>
  104. </dd>
  105. <dd class="">
  106. <a href="badge.html" tppabs="http://www.layui.com/demo/badge.html">徽章</a>
  107. </dd>
  108. <dd class="">
  109. <a href="timeline.html" tppabs="http://www.layui.com/demo/timeline.html">时间线</a>
  110. </dd>
  111. <dd class="">
  112. <a href="table-element.html" tppabs="http://www.layui.com/demo/table-element.html">静态表格</a>
  113. </dd>
  114. <dd class="">
  115. <a href="anim.html" tppabs="http://www.layui.com/demo/anim.html">动画</a>
  116. </dd>
  117. <dd class="">
  118. <a href="auxiliar.html" tppabs="http://www.layui.com/demo/auxiliar.html">辅助元素</a>
  119. </dd>
  120. </dl>
  121. </li>
  122. <li class="layui-nav-item layui-nav-itemed">
  123. <a class="javascript:;" href="javascript:;">组件示例</a>
  124. <dl class="layui-nav-child">
  125. <dd class="">
  126. <a href="layer.html" tppabs="http://www.layui.com/demo/layer.html">
  127. 弹出层
  128. </a>
  129. </dd>
  130. <dd class="">
  131. <a href="laydate.html" tppabs="http://www.layui.com/demo/laydate.html">
  132. 日期与时间选择
  133. </a>
  134. </dd>
  135. <dd class="">
  136. <a href="table.html" tppabs="http://www.layui.com/demo/table.html">
  137. 数据表格
  138. </a>
  139. </dd>
  140. <dd class="layui-this">
  141. <a href="laypage.html" tppabs="http://www.layui.com/demo/laypage.html">
  142. 分页
  143. </a>
  144. </dd>
  145. <dd class="">
  146. <a href="dropdown.html" tppabs="http://www.layui.com/demo/dropdown.html">
  147. 下拉菜单
  148. </a>
  149. </dd>
  150. <dd class="">
  151. <a href="upload.html" tppabs="http://www.layui.com/demo/upload.html">
  152. 文件上传
  153. </a>
  154. </dd>
  155. <dd class="">
  156. <a href="transfer.html" tppabs="http://www.layui.com/demo/transfer.html">
  157. 穿梭框
  158. </a>
  159. </dd>
  160. <dd class="">
  161. <a href="tree.html" tppabs="http://www.layui.com/demo/tree.html">
  162. 树形组件
  163. </a>
  164. </dd>
  165. <dd class="">
  166. <a href="colorpicker.html" tppabs="http://www.layui.com/demo/colorpicker.html">
  167. 颜色选择器
  168. </a>
  169. </dd>
  170. <dd class="">
  171. <a href="slider.html" tppabs="http://www.layui.com/demo/slider.html">
  172. 滑块
  173. </a>
  174. </dd>
  175. <dd class="">
  176. <a href="rate.html" tppabs="http://www.layui.com/demo/rate.html">
  177. 评分
  178. </a>
  179. </dd>
  180. <dd class="">
  181. <a href="carousel.html" tppabs="http://www.layui.com/demo/carousel.html">
  182. 轮播
  183. </a>
  184. </dd>
  185. <dd class="">
  186. <a href="laytpl.html" tppabs="http://www.layui.com/demo/laytpl.html">
  187. 模板引擎
  188. </a>
  189. </dd>
  190. <dd class="">
  191. <a href="layedit.html" tppabs="http://www.layui.com/demo/layedit.html">
  192. 富文本编辑器
  193. </a>
  194. </dd>
  195. <dd class="">
  196. <a href="flow.html" tppabs="http://www.layui.com/demo/flow.html">
  197. 流加载
  198. </a>
  199. </dd>
  200. <dd class="">
  201. <a href="util.html" tppabs="http://www.layui.com/demo/util.html">
  202. 工具模块
  203. </a>
  204. </dd>
  205. <dd class="">
  206. <a href="code.html" tppabs="http://www.layui.com/demo/code.html">
  207. 文本行修饰
  208. </a>
  209. </dd>
  210. </dl>
  211. </li>
  212. <li class="layui-nav-item" style="height: 30px; text-align: center"></li>
  213. </ul>
  214. </div>
  215. </div>
  216. <div class="layui-tab layui-tab-brief" lay-filter="demoTitle">
  217. <ul class="layui-tab-title site-demo-title">
  218. <li class="layui-this">预览</li>
  219. <li>查看代码</li>
  220. <li>帮助</li>
  221. </ul>
  222. <div class="layui-body layui-tab-content site-demo site-demo-body">
  223. <div class="layui-tab-item layui-show">
  224. <div class="layui-main">
  225. <div id="LAY_preview">
  226. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  227. <legend>总页数低于页码总数</legend>
  228. </fieldset>
  229. <div id="demo0"></div>
  230. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  231. <legend>总页数大于页码总数</legend>
  232. </fieldset>
  233. <div id="demo1"></div>
  234. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  235. <legend>自定义主题 - 颜色随意定义</legend>
  236. </fieldset>
  237. <div id="demo2"></div>
  238. <div id="demo2-1"></div>
  239. <div id="demo2-2"></div>
  240. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  241. <legend>自定义首页、尾页、上一页、下一页文本</legend>
  242. </fieldset>
  243. <div id="demo3"></div>
  244. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  245. <legend>不显示首页尾页</legend>
  246. </fieldset>
  247. <div id="demo4"></div>
  248. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  249. <legend>开启HASH</legend>
  250. </fieldset>
  251. <div id="demo5"></div>
  252. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  253. <legend>只显示上一页、下一页</legend>
  254. </fieldset>
  255. <div id="demo6"></div>
  256. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  257. <legend>显示完整功能</legend>
  258. </fieldset>
  259. <div id="demo7"></div>
  260. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  261. <legend>自定义排版</legend>
  262. </fieldset>
  263. <div id="demo8"></div>
  264. <div id="demo9"></div>
  265. <div id="demo10"></div>
  266. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  267. <legend>自定义每页条数的选择项</legend>
  268. </fieldset>
  269. <div id="demo11"></div>
  270. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  271. <legend>将一段已知数组分页展示</legend>
  272. </fieldset>
  273. <div id="demo20"></div>
  274. <ul id="biuuu_city_list"></ul>
  275. </div>
  276. <blockquote class="layui-elem-quote" style="margin-top: 30px;">
  277. 更多我们未能呈现的示例,还有待您在阅读文档、以及不断使用的过程,去深入挖掘。
  278. </blockquote>
  279. <div style="margin: 15px 0 100px; padding-bottom: 100px;">
  280. </div>
  281. </div>
  282. </div>
  283. <div class="layui-tab-item">
  284. <textarea class="layui-border-box site-demo-text site-demo-code" id="LAY_democode" spellcheck="false" readonly>
  285. <!DOCTYPE html>
  286. <html>
  287. <head>
  288. <meta charset="utf-8">
  289. <title>镜像站@Layui</title>
  290. <meta name="renderer" content="webkit">
  291. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  292. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  293. <link rel="stylesheet" href="/public/layui/dist/css/layui.css" tppabs="http://res.layui.com/layui/dist/css/layui.css" media="all">
  294. <!-- 注意:如果你直接复制所有代码到本地,上述css路径需要改成你本地的 -->
  295. </head>
  296. </textarea>
  297. </div>
  298. <div class="layui-tab-item">
  299. <div class="layui-main">
  300. <p></p>
  301. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
  302. <legend>相关</legend>
  303. </fieldset>
  304. <a class="layui-btn layui-btn-normal" href="../doc/modules/laypage.html" tppabs="http://www.layui.com/doc/modules/laypage.html" target="_blank">layPage文档</a>
  305. </div>
  306. </div>
  307. </div>
  308. </div>
  309. <div class="layui-footer footer footer-demo">
  310. <p>
  311. Copyright &copy; 2021 <a href="../index.html" tppabs="http://www.layui.com/">「本站仅为 layui 文档保留的镜像站点,与官方无关」</a> MIT Licensed</p>
  312. <p>
  313. <a href="../about/disclaimer.html" tppabs="http://www.layui.com/about/disclaimer.html" target="_blank">免责声明</a>
  314. <a href="../about/relatedlinks.html" tppabs="http://www.layui.com/about/relatedlinks.html" target="_blank">友链</a>
  315. <a href="javascript:;" site-event="weixinmp">公众号</a>
  316. </p>
  317. <div class="site-union">
  318. <p class="site-union-desc">
  319. <span>
  320. </span>
  321. </p>
  322. </div>
  323. </div>
  324. <script>
  325. window.global = {
  326. pageType: 'demo'
  327. ,preview: function(){
  328. var preview = document.getElementById('LAY_preview');
  329. return preview ? preview.innerHTML : '';
  330. }()
  331. };
  332. </script>
  333. <div class="site-tree-mobile layui-hide">
  334. <i class="layui-icon layui-icon-spread-left"></i>
  335. </div>
  336. <div class="site-mobile-shade"></div>
  337. <script src="/public/layui/dist/layui.js" tppabs="http://res.layui.com/layui/dist/layui.js?t=1632428048355" charset="utf-8"></script>
  338. <script>
  339. layui.config({
  340. base: '/public/static/lay/modules/layui/'
  341. ,version: '1632428048355'
  342. }).use('global');
  343. </script>
  344. </div>
  345. <div id="LAY_democodejs">
  346. <script>
  347. layui.use(['laypage', 'layer'], function(){
  348. var laypage = layui.laypage
  349. ,layer = layui.layer;
  350. //总页数低于页码总数
  351. laypage.render({
  352. elem: 'demo0'
  353. ,count: 50 //数据总数
  354. });
  355. //总页数大于页码总数
  356. laypage.render({
  357. elem: 'demo1'
  358. ,count: 70 //数据总数
  359. ,jump: function(obj){
  360. console.log(obj)
  361. }
  362. });
  363. //自定义样式
  364. laypage.render({
  365. elem: 'demo2'
  366. ,count: 100
  367. ,theme: '#1E9FFF'
  368. });
  369. laypage.render({
  370. elem: 'demo2-1'
  371. ,count: 100
  372. ,theme: '#FF5722'
  373. });
  374. laypage.render({
  375. elem: 'demo2-2'
  376. ,count: 100
  377. ,theme: '#FFB800'
  378. });
  379. //自定义首页、尾页、上一页、下一页文本
  380. laypage.render({
  381. elem: 'demo3'
  382. ,count: 100
  383. ,first: '首页'
  384. ,last: '尾页'
  385. ,prev: '<em>←</em>'
  386. ,next: '<em>→</em>'
  387. });
  388. //不显示首页尾页
  389. laypage.render({
  390. elem: 'demo4'
  391. ,count: 100
  392. ,first: false
  393. ,last: false
  394. });
  395. //开启HASH
  396. laypage.render({
  397. elem: 'demo5'
  398. ,count: 500
  399. ,curr: location.hash.replace('#!fenye=', '') //获取hash值为fenye的当前页
  400. ,hash: 'fenye' //自定义hash值
  401. });
  402. //只显示上一页、下一页
  403. laypage.render({
  404. elem: 'demo6'
  405. ,count: 50
  406. ,layout: ['prev', 'next']
  407. ,jump: function(obj, first){
  408. if(!first){
  409. layer.msg('第 '+ obj.curr +' 页');
  410. }
  411. }
  412. });
  413. //完整功能
  414. laypage.render({
  415. elem: 'demo7'
  416. ,count: 100
  417. ,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
  418. ,jump: function(obj){
  419. console.log(obj)
  420. }
  421. });
  422. //自定义排版
  423. laypage.render({
  424. elem: 'demo8'
  425. ,count: 1000
  426. ,layout: ['limit', 'prev', 'page', 'next']
  427. });
  428. laypage.render({
  429. elem: 'demo9'
  430. ,count: 1000
  431. ,layout: ['prev', 'next', 'page']
  432. });
  433. laypage.render({
  434. elem: 'demo10'
  435. ,count: 1000
  436. ,layout: ['page', 'count']
  437. });
  438. //自定义每页条数的选择项
  439. laypage.render({
  440. elem: 'demo11'
  441. ,count: 1000
  442. ,limit: 100
  443. ,limits: [100, 300, 500]
  444. });
  445. //将一段数组分页展示
  446. //测试数据
  447. var data = [
  448. '北京',
  449. '上海',
  450. '广州',
  451. '深圳',
  452. '杭州',
  453. '长沙',
  454. '合肥',
  455. '宁夏',
  456. '成都',
  457. '西安',
  458. '南昌',
  459. '上饶',
  460. '沈阳',
  461. '济南',
  462. '厦门',
  463. '福州',
  464. '九江',
  465. '宜春',
  466. '赣州',
  467. '宁波',
  468. '绍兴',
  469. '无锡',
  470. '苏州',
  471. '徐州',
  472. '东莞',
  473. '佛山',
  474. '中山',
  475. '成都',
  476. '武汉',
  477. '青岛',
  478. '天津',
  479. '重庆',
  480. '南京',
  481. '九江',
  482. '香港',
  483. '澳门',
  484. '台北'
  485. ];
  486. //调用分页
  487. laypage.render({
  488. elem: 'demo20'
  489. ,count: data.length
  490. ,jump: function(obj){
  491. //模拟渲染
  492. document.getElementById('biuuu_city_list').innerHTML = function(){
  493. var arr = []
  494. ,thisData = data.concat().splice(obj.curr*obj.limit - obj.limit, obj.limit);
  495. layui.each(thisData, function(index, item){
  496. arr.push('<li>'+ item +'</li>');
  497. });
  498. return arr.join('');
  499. }();
  500. }
  501. });
  502. });
  503. </script>
  504. </div>
  505. </body>
  506. </html>