Commit ea060d98f1dde88df6a240462c6235c6a3711dd4
1 parent
06290cb3
fix #1543
Showing
2 changed files
with
20 additions
and
2 deletions
Show diff stats
examples/routers/page.vue
| 1 | <template> | 1 | <template> |
| 2 | - <Page :total="100" show-sizer show-elevator show-total></Page> | 2 | + <div> |
| 3 | + <Page :total="total" show-sizer show-elevator show-total></Page> | ||
| 4 | + <Button type="primary" @click="subject">- 1</Button> | ||
| 5 | + </div> | ||
| 3 | </template> | 6 | </template> |
| 4 | <script> | 7 | <script> |
| 5 | export default { | 8 | export default { |
| 6 | - | 9 | + data () { |
| 10 | + return { | ||
| 11 | + total: 21 | ||
| 12 | + } | ||
| 13 | + }, | ||
| 14 | + methods: { | ||
| 15 | + subject() { | ||
| 16 | + this.total -= 1; | ||
| 17 | + } | ||
| 18 | + } | ||
| 7 | } | 19 | } |
| 8 | </script> | 20 | </script> |
src/components/page/page.vue
| @@ -135,6 +135,12 @@ | @@ -135,6 +135,12 @@ | ||
| 135 | }; | 135 | }; |
| 136 | }, | 136 | }, |
| 137 | watch: { | 137 | watch: { |
| 138 | + total (val) { | ||
| 139 | + let maxPage = Math.ceil(val / this.currentPageSize); | ||
| 140 | + if (maxPage < this.currentPage && maxPage > 0) { | ||
| 141 | + this.currentPage = maxPage; | ||
| 142 | + } | ||
| 143 | + }, | ||
| 138 | current (val) { | 144 | current (val) { |
| 139 | this.currentPage = val; | 145 | this.currentPage = val; |
| 140 | }, | 146 | }, |