带有DIV ID的路线

发布于 2025-01-20 04:50:01 字数 370 浏览 1 评论 0原文

单击并将ID传递时,如何正确路由Laravel? 我有一个使用vue,可以打印出数组的每个元素。 像这样:

<div v-for="album in albums" :key="album.id" class="border-2 w-3/4 h-48 bg-sky-500  ">
    <a href="/album/">{{ album.title  }}</a>
  </div>

您可以看到我尝试使用href来路由。我该如何通过专辑。因此,该路线将是示例localhost:8000/permul/5

感谢您的任何帮助,我也感谢。

How do you correctly route in Laravel when on click and pass the ID along?
I have a using vue that prints out every element of an array.
Like this:

<div v-for="album in albums" :key="album.id" class="border-2 w-3/4 h-48 bg-sky-500  ">
    <a href="/album/">{{ album.title  }}</a>
  </div>

As you can see im trying to route using href. How can i pass the album.id alongside that? So the route would be for an example localhost:8000/album/5

Thanks for any help, i do appreciate it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

生寂 2025-01-27 04:50:01

@gev99

感谢您的回复伴侣。

我通过这样做修复了它:

<div v-for="album in albums" :key="album.id" class="border-2 w-3/4 h-48 bg-sky-500  ">
    <a v-bind:href="'/album/'+ album.id"> {{ album.title }} </a>
  </div>

我会尝试一下您的!谢谢你!

@Gev99

Thanks for the reply mate.

I fixed it by doing this:

<div v-for="album in albums" :key="album.id" class="border-2 w-3/4 h-48 bg-sky-500  ">
    <a v-bind:href="'/album/'+ album.id"> {{ album.title }} </a>
  </div>

I will try out yours aswell! Thank you!

赠意 2025-01-27 04:50:01
//web.php
Route::get('albume/{id}',[MyController::class,'MyMethod'])->name('albume');

//在vue文件中

 <div v-for="(album,idx) in albums" :key="idx" class="border-2 w-3/4 h-48 bg-sky-500  ">
    <a :href="route('album',album.id)">{{ album.title  }}</a>
  </div>

这是最好的方法

//web.php
Route::get('albume/{id}',[MyController::class,'MyMethod'])->name('albume');

//in vue file

 <div v-for="(album,idx) in albums" :key="idx" class="border-2 w-3/4 h-48 bg-sky-500  ">
    <a :href="route('album',album.id)">{{ album.title  }}</a>
  </div>

This is the best way

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文