Laravel数据绑定在Vue模板上

时间:2019-09-14 17:07:43

标签: vue.js laravel-5 data-binding

您好,我尝试将laravel中此对象的user_name绑定到.vue:

{ "order": [ { "id": 87, "user_id": "2", "user_name": "Mohamed Hassan", "table": 20, "total": 224, "status": 1, "delivered": 0, "paied": 0, "created_at": "2019-09-14 15:04:40", "updated_at": "2019-09-14 15:04:40" } ] } 

此对象来自:

 {{order.data}}

IAM尝试

   {{order.data['order']}}

获取此

 [ { "id": 87, "user_id": "2", "user_name": "Mohamed Hassan", "table": 20, "total": 224, "status": 1, "delivered": 0, "paied": 0, "created_at": "2019-09-14 15:04:40", "updated_at": "2019-09-14 15:04:40" } ] 

可以尝试:

 {{order.data['order']['user_name']}}

但返回null

这是我的.vue温度:

<li v-for="order in orders">
            <div class="col-md-3 col-sm-3 col-xs-3"><div class="notify-img">{{order.data}}</div></div>
            <div class="col-md-9 col-sm-9 col-xs-9 pd-l0"><a href="">Date: </a>  <a href="">{{order.created_at}}</a> <a href="" class="rIcon"><i class="fa fa-dot-circle-o"></i></a>
            <p>Lorem ipsum sit dolor amet consilium.</p>
            <p class="time">1 Saat önce</p>
            <hr>
            </div>

        </li>

1 个答案:

答案 0 :(得分:0)

{{order.data['order']}}返回一个数组,您可以使用以下索引来访问其项目:

  {{order.data['order'][0]['user_name']}}