美好的一天,我是Vuejs
的初学者,我正在尝试获取表格中的一些数据..这是我的代码。
我的JS:
Vue.http.headers.common['X-CSRF-TOKEN'] = $("#token").attr("value");
new Vue({
el: '#incomings',
methods : {
getDv: function () {
this.$http.get('/api/data', function (data) {
this.$set('dv', data)
})
}
},
ready : function () {
this.getDv()
}
});
我的看法:
<div class="container" id="incomings">
<table class="table table-bordered">
<tr>
<th>no</th>
</tr>
<tr v-for="a in dv">
<td>@{{ a.id }}</td>
</tr>
</table>
</div>
我的路线:
Route::get('/data', 'DvController@incomingsData');
Route::get('/test', 'DvController@incomings');
我的控制器:
//API's
public function incomingsData(){
return DV::all();
}
public function incomings(Request $request, DV $disbVchr){
return view('admin.dv.dv-incomings');
}
我在浏览器中检查了它并且它响应了一系列JSON
,但它没有显示在桌面上。 ..