首页 > 解决方案 > 如何单击按钮并使用按钮所在项目的项目 ID 将其发送到另一个视图。Laravel - vue.js - 惯性 vue

问题描述

我正在制作一个包含讨论论坛并且用户必须回答它们的仪表板,我希望它向具有讨论论坛信息的卡片添加一个按钮,并打开用户可以添加评论的视图。但是为了能够回答正确的论坛,我需要发送用户点击的论坛 ID。

我已经尝试过使用inertia-link@click 按钮。这是我的路线

Route::resource('comments', 'ReplyController', ['except' => ['index']]);
Route::get('comments/{id}', 'ReplyController@index');

在控制器中

public function index($id)
{
    $forum = DiscussionForum::where('id', $id)
        ->with('comment', 'user')->first();
    $comment = ForumReply::with('discussionForum', 'user')
        ->where('discussion_forum_id', $forum->id)
        ->orderByDesc('comment_time')->get();

    return Inertia::render('Forum/Comment.vue', [
        'forum' => $forum,
        'comments' => $comment
    ]);
}

这是我尝试过的,这会将我带到页面,但它是空白的,不应该是

<a class="el-button el-button--warning"
:href="'comments/' + f.id"> Contestar </a>

这样做的正确方法是什么?

标签: html

解决方案


推荐阅读