【问题标题】:Method App\Http\Controllers\ProductController::getIndex()() does not exist方法 App\Http\Controllers\ProductController::getIndex()() 不存在
【发布时间】:2017-08-01 15:10:45
【问题描述】:

web.php 文件

这是我使用 laravel 5.4 的 web.php 文件

<?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');
    }
}

如何摆脱这个错误请帮助我。

这有什么问题?

【问题讨论】:

    标签: laravel laravel-5 laravel-routing laravel-5.4


    【解决方案1】:

    您不应在路由定义中使用()。应该是:

    Route::get('/', [
    
                'uses' =>'ProductController@getIndex',
                'as' =>'product.index'
    
        ]);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-25
      • 1970-01-01
      • 2021-04-04
      • 2020-05-08
      • 1970-01-01
      • 1970-01-01
      • 2020-10-15
      • 2023-03-17
      相关资源
      最近更新 更多