簡體   English   中英

無法調用方法在Laravel中返回VIEW

[英]Can't call a method to return a VIEW in Laravel

我不知道為什么不能用其他方法返回視圖,這很簡單:在routes.php中,我有:

Route::get('/viewer', 'ViewerController@index');

這在ViewerController.php起作用

public function index()
{
   return view('viewer'); 
}

但是,這不起作用:

public function index()
{
   $this->generalViewer(); 
}

public function generalViewer()
{
   return view('viewer');
}

我沒有錯誤,只是什么也沒有返回。 為什么?

解決方案是:

public function index()
{
   // Return what `generalViewer()` returns
   return $this->generalViewer(); 
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM