在v-for laravel-vue中显示 [英] Display in v-for laravel-vue

查看:76
本文介绍了在v-for laravel-vue中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Vue.js,但遇到了我的对象JSON字符串不显示的问题.

I'm using Vue.js and I'm having an issue that my object JSON-string doesn't show.

问题是对象字符串未在v-for中显示.

The problem is the object string doesn't display in v-for.

JS

var app = new Vue({
    el: '#ob-rapper',

    data:{
        items:[],
    },
    mounted: function mounted(){
        this.getVueItems();
    },
    methods:{
        getVueItems: function getVueItems() {
          var _this = this;
          axios.get('/viewrequestsample').then(function (response) {
            _this.items = response.data;
          });
        }
    }
});

控制器:

public function viewRequestSample(){
    $data = OBMaster::all();
    return $data;
}

路线:

Route::get ( '/requestsample', function () {
    return view ( 'Approvers.RequestSample' );
} );
Route::get('/viewrequestsample', 'AdminPagesController@viewRequestSample');

HTML:

<div class="card">
  <div id="ob-rapper">
    <div class="card-body">
      <table class="table table-striped table-bordered bootstrap-datatable datatable responsive dataTable" id="DataTables_Table_0" aria-describedby="DataTables_Table_0_info">
        <thead>
          <tr role="row">
            <th class="sorting" role="columnheader" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="Date registered: activate to sort column ascending" >
              Name of Employee
            </th>
            <th class="sorting" role="columnheader" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="Role: activate to sort column ascending" >
              Date Filed
            </th>
            <th class="sorting" role="columnheader" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="Status: activate to sort column ascending">
              Status
            </th>
            <th class="sorting" role="columnheader" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="Actions: activate to sort column ascending">
              Actions
            </th>
          </tr>
        </thead>
        {{ csrf_field() }}
        <p class="text-center alert alert-success">Deleted Successfully!</p>

        <tbody role="alert" aria-live="polite" aria-relevant="all">
           <tr v-for="item in items">
              <td>@{{ item.id }}</td>
              <td>@{{ item.emp_id }}</td>
              <td>@{{ item.date_filed }}</td>
              <td>@{{ item.obdate}}</td>
              <td>@{{ item.obfrom}}</td>
              <td>@{{ item.obto}}</td>
              <td>@{{ item.created_a}}</td>
              <td>@{{ item.updated_at}}</td>
              <td id="show-modal" class="btn btn-info" ><span
                        class="glyphicon glyphicon-pencil"></span></td>
              <td id="show-modal" class="btn btn-danger"><span
                            class="glyphicon glyphicon-trash"></span></td>
           </tr>            
        </tbody>
    </table>
   </div>
  </div>
</div>

............................................... ................................................... ................................................... .....

..............................................................................................................................................................

推荐答案

您的data必须是返回数据的函数.

Your data must be a function that returns your data.

赞:

data() {
    return {
        items:[]
    }
}

问题:您的插值标签是否正确定义为@ {{}}?

Question: Is your interpolation tag defined to @{{}} correctly?

这篇关于在v-for laravel-vue中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆