关于method not exist:think\db\Query->render错误...

复制代码 
{volist name="Teachers" id="Teachers" key="key"} 
 
{$key} 
{$Teachers->getData('name')} 
{eq name='$Teachers->getData("sex")' value='0'}男{else /}女{/eq} 
{$Teachers->getData('email')} 
{$Teachers->getData('username')} 
编辑   
删除 
 
{/volist} 
 
当前页总条数{$Teachers->count()} 
{$Teachers->render()} 

 

上面是 html 




public function index() 

try{ 
$pagesize = 10; 
$Teacher = new Teacher; 
//$Teachers = $Teacher->select(); 
$Teachers = $Teacher->paginate($pagesize); 
// $teacher = $Teachers[0]; 
//var_dump($teacher->getData()); 
//echo '
'; 
//echo $teacher->getData('name'); 
//echo '
'; 
//return $teacher->getData('name'); 
$this->assign('Teachers',$Teachers);//像视图传递数据 
//取回打包后的数据 
$htmls = $this->fetch(); 
//将数据返回给用户 
return $htmls; 
}catch(\think\Exception\httpResponseException $e){ 
throw $e; 
}catch(\Exception $e){ 
return $e->getMessage(); 



上面是PHP 



最开始是上面那样的方法 



解决方案: 


 

 
 增加 

 
 
 
 
 
 
 
 
 
 
{volist name="Teachers" id="Teachers" key="key"} 
 
 
 
 
 
 
 
 
{/volist} 
序号 姓名 性别 邮箱 用户名 操作
{$key} {$Teachers->getData('name')} {eq name='$Teachers->getData("sex")' value='0'}男{else /}女{/eq} {$Teachers->getData('email')} {$Teachers->getData('username')} 编辑   
删除
 
当前页总条数{$Teachers->count()} 
{$page} 
 

PHP 


public function index() 

try{ 
$pagesize = 10; 
$Teacher = new Teacher; 
//$Teachers = $Teacher->select(); 
$Teachers = $Teacher->paginate($pagesize); 
$page = $Teachers->render(); 
    //调用render()方法 新添加的这里 
// $teacher = $Teachers[0]; 
//var_dump($teacher->getData()); 
//echo '
'; 
//echo $teacher->getData('name'); 
//echo '
'; 
//return $teacher->getData('name'); 
$this->assign('Teachers',$Teachers);//像视图传递数据 
$this->assign('page',$page);//这里要重新传递一下 
$htmls = $this->fetch(); 
//将数据返回给用户 
return $htmls; 
}catch(\think\Exception\httpResponseException $e){ 
throw $e; 
}catch(\Exception $e){ 
return $e->getMessage(); 

}//千锋PHP-PHP培训的实力派 

转载于:https://my.oschina.net/u/3432750/blog/917583

你可能感兴趣的:(关于method not exist:think\db\Query->render错误...)