public function index()
{
$map = [];
if($this->request->isGet()) {
$data = $this->request->get();
if (!empty($data['id'])) {
$map['id'] = $data['id'];
}
//模糊查询
if (!empty($data['itemname'])) {
$map['itemname'] = ['like', "%{$data['itemname']}%"];
}
$this->assign('map',$map);
}
$propList = ($this->prop_model->where($map)->paginate(15,false,['query' => request()->param()]));
$this->assign('propList',$propList);
return $this->fetch('index');
}
直接用render ok
<table class="layui-table">
<colgroup>
<col width="150">
<col width="150">
<col>
</colgroup>
<thead>
<tr>
<th style="width: 30px;">ID</th>
<th>道具名称</th>
</tr>
</thead>
<tbody>
{empty name="propList"}
<tr colspan="30" style="text-align: center"><span class="">暂无此数据!</span></tr>
{else /}
{foreach name="propList" item="vo"}
<tr>
<td>{$vo.id}</td>
<td>{$vo.itemname}</td>
</tr>
{/foreach}
</tbody>
</table>
<!--分页-->
{$propList->render()}
{/empty}