【问题标题】:How to pass a vue.js value as a parameter to a route in blade如何将 vue.js 值作为参数传递给刀片中的路由
【发布时间】:2017-04-01 23:41:18
【问题描述】:

我在 Laravel 中有一条需要 id 作为参数的路由。

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

如果我将数据从 Laravel 控制器传递到视图值,我会像这样传递它:

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

但我的idvue 值:

<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>

正确的方法是什么?

【问题讨论】:

    标签: javascript php laravel-5 vue.js


    【解决方案1】:

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

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

    【讨论】:

    • @PhillisPeters 已更新。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-07-01
    • 2019-08-12
    • 2019-05-26
    • 2023-03-13
    • 2018-07-07
    • 2018-04-30
    相关资源
    最近更新 更多