方法 App\Http\Controllers\ProductController::getIndex()() 不存在
Method App\Http\Controllers\ProductController::getIndex()() does not exist
web.php 文件
这是我的 web.php 文件,使用 laravel 5.4
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', [
'uses' =>'ProductController@getIndex()',
'as' =>'product.index'
]);
ProductController.php
这是我使用 laravel5.4
的控制器文件
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class ProductController extends Controller
{
//
public function getIndex(){
return view('shop.index');
}
}
请帮助我如何摆脱这个错误。
有什么问题吗?
您不应在路由定义中使用 ()
。应该是:
Route::get('/', [
'uses' =>'ProductController@getIndex',
'as' =>'product.index'
]);
web.php 文件
这是我的 web.php 文件,使用 laravel 5.4
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', [
'uses' =>'ProductController@getIndex()',
'as' =>'product.index'
]);
ProductController.php
这是我使用 laravel5.4
的控制器文件<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class ProductController extends Controller
{
//
public function getIndex(){
return view('shop.index');
}
}
请帮助我如何摆脱这个错误。
有什么问题吗?
您不应在路由定义中使用 ()
。应该是:
Route::get('/', [
'uses' =>'ProductController@getIndex',
'as' =>'product.index'
]);