webman分页报错

xuanzeweini

问题描述

按照手册的代码,采用的thinkphp的模板,无法循环输出$user列表的值

程序代码

控制器代码
 $per_page = 1;
 $current_page = $request->input('page', 1);
 $users = Db::table('mj_users')->paginate($per_page, '*', 'page',    $current_page);
 $paginator = new Paginator($users->total(), $per_page, $current_page, '/user/all?page=(:num)');
 return view('user/all', ['users' => $users->toArray(), 'paginator'  => $paginator]);

模板代码
<body>
{volist name='users' id='user'}
帐号:{$user->uname}--姓名:{$user->rname}<br>
{/volist}
<div class="center">{$paginator}</div>
</body>

报错信息

ErrorException: Attempt to read property "uname" on int in D:\phpstudy_pro\WWW\webman\runtime\views\088e93a6edfd3c26a765f33e4eee68f5.php:38
Stack trace:

截图报错信息里报错文件相关代码

如果控制器'users' => $users不加->toArray(),不报错,但是也不显示任何信息。

操作系统及workerman/webman等框架组件具体版本

windows10、Workerman version:4.1.13 PHP version:8.0.2

179 1 0
1个回答

xuanzeweini

已解决,谢谢
$users->toArray()['data']

  • 暂无评论
🔝