Skip to content

Commit 205d266

Browse files
committed
update
1 parent 92ca36e commit 205d266

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

README.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
## Support
77
> Laravel 5.x and Vue 2.x
88
## npm
9-
```
9+
```
1010
npm install vue2-laravel-pagination --save-dev
1111
```
1212
## yarn
13-
```
13+
```
1414
yarn add vue2-laravel-pagination --save-dev
1515
```
1616
## Then
@@ -21,7 +21,7 @@ import Pagination from 'vue2-laravel-pagination'
2121
```$xslt
2222
public function getQuestion() {
2323
$questions = Question::paginte(5);
24-
24+
2525
return response()->json($questions, 200);
2626
}
2727
```
@@ -45,10 +45,26 @@ total: 25
4545
:current="questions.current_page"
4646
:total="questions.total"
4747
:per-page="questions.per_page"
48+
@page-changed="fetchData"
4849
>
4950
</pagination>
5051
</template>
5152
```
53+
> The $emit('page-changed') is triggering when the page paginate numbers or next button clicked, so you must write that method to fetch next page with your data.
54+
## Example
55+
```
56+
methods: {
57+
fetchData(page) {
58+
page = page || 1
59+
axios.get('http://yurist/api/filter/all?page=' + page)
60+
.then(response => {
61+
this.questions = response.data
62+
this.questions.current_page = page
63+
})
64+
.catch(err => consolel.log(err))
65+
}
66+
}
67+
````
5268
> Styles are written within the component. You can edit or delete them, depends on you.
5369
## Props
5470
```
@@ -75,6 +91,7 @@ props: {
7591
}
7692
```
7793
> You can play with the `pageRange` and set it for your needs.
94+
7895
## Manually
7996
Just download src/components/Pagination.vue file and import it to your **.vue** tamplate.
8097
```$xslt

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue2-laravel-pagination",
3-
"version": "1.0.1",
3+
"version": "1.0.3",
44
"description": "A vue2 Laravel Paginator",
55
"author": "Valijon <[email protected]>",
66
"main": "src/components/Pagination.vue",

0 commit comments

Comments
 (0)