【发布时间】:2017-02-12 01:36:14
【问题描述】:
我的ajax是这样的:
<script>
new Vue({
...
methods: {
fetchItems: function (page) {
var data = {page: page};
this.$http.get('api/items', data).then(function (response) {
console.log(JSON.stringify(response))
this.$set(this, 'items', response.data.data.data);
this.$set(this, 'pagination', response.data.pagination);
}, function (error) {
// handle error
});
},
...
}
});
</script>
我的路线是这样的:
Route::get('/api/items/', function () {
dd(Input::get('page'));
$results = \App\Post::latest()->paginate(7);
$response = [
'pagination' => [
'total' => $results->total(),
'per_page' => $results->perPage(),
'current_page' => $results->currentPage(),
'last_page' => $results->lastPage(),
'from' => $results->firstItem(),
'to' => $results->lastItem()
],
'data' => $results
];
return $response;
});
执行时,我在控制台上检查,结果 = null,而我输入的是:dd(Input::get('page'));
是否应该显示发送者的页面
我该如何解决?
【问题讨论】:
标签: javascript laravel vue.js laravel-5.3 vuejs2