Commit 6355250e52b0f128115ebe221c02fb22df1c3925
1 parent
f3c6cd68
emit current update when page changed
Showing
2 changed files
with
8 additions
and
1 deletions
Show diff stats
examples/routers/page.vue
| 1 | <template> | 1 | <template> |
| 2 | <div> | 2 | <div> |
| 3 | - <Page :total="total" show-sizer show-elevator show-total></Page> | 3 | + <Page :total="total" show-sizer show-elevator show-total :current.sync="current"></Page> |
| 4 | + {{ current }} | ||
| 4 | <Button type="primary" @click="subject">- 1</Button> | 5 | <Button type="primary" @click="subject">- 1</Button> |
| 6 | + <Button type="primary" @click="change">Change</Button> | ||
| 5 | </div> | 7 | </div> |
| 6 | </template> | 8 | </template> |
| 7 | <script> | 9 | <script> |
| 8 | export default { | 10 | export default { |
| 9 | data () { | 11 | data () { |
| 10 | return { | 12 | return { |
| 13 | + current: 1, | ||
| 11 | total: 21 | 14 | total: 21 |
| 12 | } | 15 | } |
| 13 | }, | 16 | }, |
| 14 | methods: { | 17 | methods: { |
| 15 | subject() { | 18 | subject() { |
| 16 | this.total -= 1; | 19 | this.total -= 1; |
| 20 | + }, | ||
| 21 | + change() { | ||
| 22 | + this.current = 1; | ||
| 17 | } | 23 | } |
| 18 | } | 24 | } |
| 19 | } | 25 | } |
src/components/page/page.vue
| @@ -214,6 +214,7 @@ | @@ -214,6 +214,7 @@ | ||
| 214 | changePage (page) { | 214 | changePage (page) { |
| 215 | if (this.currentPage != page) { | 215 | if (this.currentPage != page) { |
| 216 | this.currentPage = page; | 216 | this.currentPage = page; |
| 217 | + this.$emit('update:current', page); | ||
| 217 | this.$emit('on-change', page); | 218 | this.$emit('on-change', page); |
| 218 | } | 219 | } |
| 219 | }, | 220 | }, |