web.php 中出现命名参数错误后无法使用位置参数
Cannot use positional argument after named argument error in web.php
Route::get(uri: 'scraper', ["App\Http\Controllers\ScraperController"::class, 'scraper'])->name(name:'scraper');
我在web.php
中写了这一行,然后我得到了这个错误:
'Cannot use positional argument after named argument'
您试图在不必要时使用命名参数定义路由。你应该这样写:
Route::get('scraper', [App\Http\Controllers\ScraperController::class, 'scraper'])->name('scraper');
您可以详细了解 named arguments 以及它们与位置参数的区别。
如果你想继续使用命名的agruments,可以这样做
Route::get(
uri: 'scraper',
action: [App\Http\Controllers\ScraperController::class, 'scraper']
)
->name(name:'scraper');
Route::get()
的定义就像
/**
*
* @param string $uri
* @param array|string|callable|null $action
* @return \Illuminate\Routing\Route
*/
public static function get($uri, $action = null){}
Route::get(uri: 'scraper', ["App\Http\Controllers\ScraperController"::class, 'scraper'])->name(name:'scraper');
我在web.php
中写了这一行,然后我得到了这个错误:
'Cannot use positional argument after named argument'
您试图在不必要时使用命名参数定义路由。你应该这样写:
Route::get('scraper', [App\Http\Controllers\ScraperController::class, 'scraper'])->name('scraper');
您可以详细了解 named arguments 以及它们与位置参数的区别。
如果你想继续使用命名的agruments,可以这样做
Route::get(
uri: 'scraper',
action: [App\Http\Controllers\ScraperController::class, 'scraper']
)
->name(name:'scraper');
Route::get()
的定义就像
/**
*
* @param string $uri
* @param array|string|callable|null $action
* @return \Illuminate\Routing\Route
*/
public static function get($uri, $action = null){}