現在LaravelとVueJSでアプリを作成中です。
LaravelのPaginationを使い、ページングのメタ情報を含めてレスポンスを返すようコードを書いています。
現状
・Example.vueが呼ばれた際、見た目上のURIが「http://..../example」(vue-routerのURIが優先される)
やりたいこと
URIを「http://..../example?page=...」となるようコーディング
javascript
1const router = new VueRouter({ 2 mode: 'history', 3 routes: [ 4 { path: '/', name: 'home', component: Index}, 5 { path: '/example/', name: 'example', component: Example}, 6 ] 7}) 8 9export default router
javascript
1 2// Example.vue 3 4<template> 5 ... 6</template> 7 8<script> 9import { get } from '../connectio/api' 10 11export default { 12 data() { 13 return { 14 data : [], 15 counter: 0, 16 pagination: { 17 total: 0, 18 per_page: 8, 19 from: 1, 20 to: 0, 21 current_page: 1 22 }, 23 offset: 2, 24 } 25 }, 26 mounted : function() { 27 this.getPage(this.pagination.current_page); 28 }, 29 methods: { 30 getPage(page) { 31 get(`/api/example?page=` + page) 32 .then((res) => { 33 this.pagination = res; 34 this.data = res.data; 35 }) 36 .catch((err) => { 37 // error 38 }) 39 40 }, 41 } 42} 43</script>
追加の必要情報等ありましたら、お手数ですがコメントいただければと思います。
よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/08/31 11:58