【问题标题】:Call a laravel Route from Vue从 Vue 调用 laravel 路由
【发布时间】:2023-04-01 23:44:01
【问题描述】:

我有一条这样的 Laravel 路线

Route::get('/{room:slug}', [RoomController::class, 'show'])->name('show');

我以为就这么简单

:href="route('name.show', room.slug)"

或者

"{{ route('chat-rooms.show', project.slug) }}"

或者

methods: {
 projectUrl(project) {
    return "{{ route('chat-rooms.show') }}/" + project.slug;
},
<a :href=projectUrl(room)></a>

或者像我在互联网上找到的其他 20 种解决方案中的任何一种。无 工作。我不明白...我可以从我的刀片文件中传递这个,就像可能一样

<component :test= "{{ route('name.show', NEEDSLUGHERE) }}"> </component>

【问题讨论】:

  • 欢迎来到SO ...结账github.com/tighten/ziggy
  • 嘿,我用过,效果很好。谢谢,这很容易和无痛
  • 很好地保持这个发布它可能对其他人也有帮助

标签: html laravel vue.js


【解决方案1】:

tighten 提供了很棒的包 你可以使用

https://github.com/tighten/ziggy

【讨论】:

    猜你喜欢
    • 2019-02-18
    • 1970-01-01
    • 2021-02-08
    • 2019-11-04
    • 2018-11-30
    • 2018-03-27
    • 2021-07-11
    • 2020-12-25
    • 2020-07-28
    相关资源
    最近更新 更多