在本地化前缀下使用 livewire 路由时出现 404 错误!
当我写下Livewire的路线时
Route::view('/counter','dashboard.counterPage');
在loczlization前缀和中间件下我收到404错误
而且,当我把它写在它们上面时,代码运行正确
routes\web.php中有代码
<?php
use App\Http\Controllers\ProfileController;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/
require __DIR__.'/auth.php';
Route::view('/counter','dashboard.counterPage'); #### the route the run correctly ####
Route::get('/', function () {
return view('welcome');
});
// Route::get('/dashboard', function () {
// return view('dashboard');
// })->middleware(['auth', 'verified'])->name('dashboard');
Route::middleware('auth')->group(function () {
Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
});
Route::group(
[
'prefix' => LaravelLocalization::setLocale(),
'middleware' => [ 'localeSessionRedirect', 'localizationRedirect', 'localeViewPath', 'auth' ]
], function(){
Route::group(['prefix'=>'/dashboard'], function () {
Route::view('/counter','dashboard.counterPage'); #### the route that get an error ####
代码在Http\Livewire\Counter.php
<?php
namespace App\Livewire;
use Livewire\Component;
class Counter extends Component
{
public $count = 0;
public function increment()
{
$this->count++;
}
public function render()
{
return view('livewire.counter');
}
}
view\livewir中有代码