按照手册的代码,采用的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(),不报错,但是也不显示任何信息。
windows10、Workerman version:4.1.13 PHP version:8.0.2
已解决,谢谢
$users->toArray()['data']