1

有人可以告诉我在尝试编辑我的帖子时如何仍然拥有漂亮的 URL?我有蛞蝓等,但对于编辑方法,我们需要使用 GET|HEAD 这意味着我们将有这样的东西:

www.our-domen.com/admin/posts/this-is-my-post-for-edit/edit?_token=0GXpk4oaLdGy8YOdp0591ogAOIHF89ZCciWk79h&btn-editPost=

而不是这个:

www.our-domen.com/admin/posts/this-is-my-post-for-edit/edit

这是代码的一部分:

<td>
  <form action="{{ route('posts.edit', $post->slug) }}" method="get">
    @csrf
    <button type="submit" name="btn-editPost" class="btn btn-info btn-sm" style="color: white;">Edit</button>
  </form>
</td>

注意:蛞蝓设置正确,这不是问题:)

4

1 回答 1

0

您实际上不需要 ,如果您只是 delete @csrf,它将起作用。

或者,更改您的代码:

<td>
   <form action="{{ route('posts.edit', $post->slug) }}" method="get">
      @csrf
      <button type="submit" name="btn-editPost" class="btn btn-info btn-sm" style="color: white;">Edit</button>
   </form>
<td>

到,

<td>
   <a href="{{ route('posts.edit', $post->slug) }}" type="button" class="btn btn-info btn-sm" style="color: white;">Edit</a>
</td>
于 2020-08-22T10:11:13.753 回答