Ich versuche, Daten aus der Datenbank mit Laravel und Vue.js zu holen. Ergebnis Ich bekomme keine. Aber Firebug Konsole zeigt die Antwort. Bitte finden Sie das angehängte Bild. Bitte überprüfe meinen Code und korrigiere mich. Daten holen aus der Datenbank mit Laravel und Vuejs
data.blade.php
@extends('layouts.app')
@section('title', 'Customers List')
@section('styles')
@endsection
@section('content')
<div class="container">
<div class="row">
<div class="col-md-10 col-md-offset-1">
<div class="panel panel-default">
<div class="panel-heading">Customers List</div>
<div class="panel-body">
<table class="table table-hover table-bordered" id="app">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Reference ID</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$i=1;
?>
<tr v-for="message in messages">
<td> {{ $i }} </td>
<td> @{{ message.name }} </td>
<td> @{{ message.reference_id }} </td>
<td><a href="/customers/list/process/" class="btn btn-primary btn-xs" role="button">Click Here</a></td>
</tr>
<?php $i++; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
@endsection
@section('scripts')
<script src="/js/vue.js"></script>
<script src="/js/vue-resource.min.js"></script>
<script src="/js/customers.js"></script>
@endsection
customers.js
new Vue({
el: '#app',
ready: function() {
this.fetchMessages();
},
methods: {
fetchMessages: function() {
this.$http.get('/customers/list/data', function(messages) {
alert(messages);
this.$set('messages', messages);
});
}
}
});
-Controller
public function showCustomersData()
{
$listCustomers = Customer::select('id', 'name', 'reference_id')
->orderBy('id', 'desc')
->get();
return response()->json(['messages' => $listCustomers]);
}
Strecke
Route::get('/customers/list/data', [
'as' => 'customerListData', 'uses' => '[email protected]'
]);
Noch Ergebnis ist keine. Ich verwende vue js Version 1.0.20 –