php 使用Livewire + mcamara/laravel-localization的POST 404

pxy2qtax  于 2023-09-29  发布在  PHP
关注(0)|答案(3)|浏览(88)

这是我的网络路线

Route::group(
    [
        'prefix' => LaravelLocalization::setLocale(),
        'middleware' => [ 'localeSessionRedirect', 'localizationRedirect', 'localeViewPath']
    ], function(){

        Route::group(['prefix' => 'admin'], function () {

            Route::get('/', 'AdminController@index')->name('admin.index');

            Route::get('/adminlogin', 'AdminControllers\AdminLoginController@index')->name('adminlogin');
            Route::post('/adminPostLogin', 'AdminControllers\AdminLoginController@login')->name('adminPostLogin');

当我尝试在Liveware中做一些事情时,给予这样的错误!!!

Failed to load resource: the server responded with a status of 404 (Not Found)

但是当我评论中间件时,Liveware正在工作,所以我应该做什么请给我建议!!!

mtb9vblg

mtb9vblg1#

它是工作我只是添加此代码内的网页

Route::post('livewire/message/{name}', '\Livewire\Controllers\HttpConnectionHandler');
zte4gxcn

zte4gxcn2#

您必须配置Livewire的更新端点。
文档https://livewire.laravel.com/docs/installation#configuring-livewires-update-endpoint中对此进行了描述

l7wslrjt

l7wslrjt3#

对于livewire 3,在web.php的本地化中添加以下代码:

Route::group(
        [
            'prefix' => LaravelLocalization::setLocale(),
            'middleware' => ['localeSessionRedirect', 'localizationRedirect', 'localeViewPath']
        ],
        function () {
            Livewire::setUpdateRoute(function ($handle) {
                return Route::post('/livewire/update', $handle);
            });
    
            Route::get('/', WebsiteHomepage::class)->name('website.homepage');
});

相关问题