【问题标题】:Laravel-8 . 404 error page on delete a postLaravel-8 .删除帖子时出现 404 错误页面
【发布时间】:2021-09-13 20:40:20
【问题描述】:

我正在使用

web.php 内:

Route::post('/delete',[PostController::class,'destroy'])->name('post.delete');

&&

刀片模板内:

<form   method="POST" class="d-inline" action="{{route('post.delete')}}">
    @csrf
    <input type="hidden" name="slug" value="{{ $post->slug }}">
    <button type="submit" class="btn px-0 d-inline">Delete</button>
</form>

问题是:当我点击删除按钮时,抛出 404 异常

Github 仓库:https://github.com/Khokon-Chandra/Blog-Backend.git

【问题讨论】:

  • 你是不是错过了那里的路由模型绑定???

标签: routes http-status-code-404 laravel-8


【解决方案1】:

尝试使用:

Route:delete('/delete',[PostController::class,'destroy'])

并添加

@method('delete')

@csrf之后的刀片内部

【讨论】:

    猜你喜欢
    • 2022-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-26
    • 2012-02-23
    • 1970-01-01
    • 2021-03-19
    相关资源
    最近更新 更多