简体   繁体   English

如何将 vue.js 值作为参数传递给刀片中的路由

[英]How to pass a vue.js value as a parameter to a route in blade

I have a route in Laravel that requires an id as a parameter.我在 Laravel 中有一条需要 id 作为参数的路线。

Route::get('/example/{id}', ExampleController@index)

If I had passed the data from the Laravel controller to the view value I would pass it like this:如果我将数据从 Laravel 控制器传递到视图值,我会像这样传递它:

<a href="/example/{{id}}" class="button success">Click</a>

But my id is a vue value:但我的id是一个vue值:

<tr v-for="item in items">
            <td>@{{ item.id }}</td>
            <td>@{{ item.name }}</td>
            <td>@{{ item.number }}</td>
            <td>@{{ item.address}}</td>
            <td v-if="item.status==0"><a href="/example/@{{item.id}}" class="button success">Click</a></td>
        </tr>

Which is the correct way to do this?执行此操作的正确方法是什么?

您可以为此使用v-bind ,如下所示:

<a :href="'/example/' + item.id" class="button success">Click</a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM