thinkphp8+layui分页

前端

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>demo</title>
  <link href="//unpkg.com/layui@2.9.20/dist/css/layui.css" rel="stylesheet">
</head>
<body>
<table class="layui-table">
  <colgroup>
    <col width="150">
    <col width="150">
    <col>
  </colgroup>
  <thead>
  <tr>
    <th>ID</th>
    <th>realname</th>
    <th>gender</th>
  </tr>
  </thead>
  <tbody>
  {volist name="data" id="vo"}
  <tr>
    <td>{$vo.id}</td>
    <td>{$vo.realname}</td>
    <td>{$vo.sex}</td>
  </tr>
  {/volist}
  </tbody>
</table>
<div id="demo-laypage-all"></div>
<script src="//unpkg.com/layui@2.9.20/dist/layui.js"></script>
<script>
  layui.use(function(){
    const laypage = layui.laypage;
    // 完整显示
    laypage.render({
      elem: 'demo-laypage-all', // 元素 id
      theme: '#1E9FFF',
      count: 100, // 数据总数
      curr:{$page},
      layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip'], // 功能布局
      jump: function(obj, first){
        console.log(obj);
        if(!first){
          window.location.href='?page='+obj.curr;
        }
      }
    });
  });
</script>
</body>
</html>

后端:

php 复制代码
public function index()
    {
        $page = input('get.page/d'); // 当前页码
        $result = Db::name('user')->paginate([
            'list_rows'=> 10,
            'page' => $page
        ]);
        return view('/index',['data'=>$result,'page'=>$page]);
    }
相关推荐
一人の梅雨6 分钟前
中国制造网商品详情接口进阶实战:跨境场景下的差异化适配与问题攻坚
java·前端·javascript
无知的小菜鸡11 分钟前
React:使用高阶组件实现vue中的路由守卫功能
前端·vue.js·react.js
xzl0412 分钟前
小智服务器intent_type 初始化为function_call过程
linux·前端·数据库
wuhen_n16 分钟前
Webpack vs Vite:前端构建工具对比
前端·webpack·node.js·vite
EverydayJoy^v^17 分钟前
RH134学习进程——四.归档和传输文件
服务器·前端·网络
muddjsv24 分钟前
JavaScript 结合 Flex 布局的深度解析 (解锁前端布局新范式)
前端·javascript
卿着飞翔25 分钟前
win11安装配置nginx并部署ruoyi前端
运维·前端·nginx
jiayong2325 分钟前
前端性能优化系列(一):问题分析与诊断
前端·性能优化
小宇的天下28 分钟前
Calibre :Standard Verification Rule Format(SVRF) Manual (1-2)
前端·javascript·windows
GGGG寄了29 分钟前
HTML——表单标签
前端·html