Pagination: add prev-click and next-click events (#10755)

pull/10771/head
杨奕 2018-04-17 16:47:32 +08:00 committed by GitHub
parent d7e9e6173f
commit 95e168f7ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 40 additions and 4 deletions

View File

@ -226,8 +226,10 @@ Add more modules based on your scenario.
### Events
| Event Name | Description | Parameters |
|---------|--------|---------|
| size-change | triggers when `page-size` changes | the new `page-size` |
| current-change | triggers when `current-page` changes | the new `current-page` |
| size-change | triggers when `page-size` changes | the new page size |
| current-change | triggers when `current-page` changes | the new current page |
| prev-click | triggers when the prev button is clicked and current page changes | the new current page |
| next-click | triggers when the next button is clicked and current page changes | the new current page |
### Slot
| Name | Description |

View File

@ -214,6 +214,8 @@ Agrega más modulos basados en su escenario.
| ----------------- | --------------------------------------- | ----------------------------- |
| size-change | se dispara cuando `page-size` cambia | nuevo valor de `page-size` |
| current-change | se dispara cuando `current-page` cambia | nuevo valor de `current-page` |
| prev-click | triggers when the prev button is clicked and current page changes | the new current page |
| next-click | triggers when the next button is clicked and current page changes | the new current page |
### Slot
| Nombre | Descripción |

View File

@ -226,8 +226,10 @@
### Events
| 事件名称 | 说明 | 回调参数 |
|---------|--------|---------|
| size-change | pageSize 改变时会触发 | 每页条数`size` |
| current-change | currentPage 改变时会触发 | 当前页`currentPage` |
| size-change | pageSize 改变时会触发 | 每页条数 |
| current-change | currentPage 改变时会触发 | 当前页 |
| prev-click | 用户点击上一页按钮改变当前页后触发 | 当前页 |
| next-click | 用户点击下一页按钮改变当前页后触发 | 当前页 |
### Slot
| name | 说明 |

View File

@ -306,6 +306,7 @@ export default {
if (this.disabled) return;
const newVal = this.internalCurrentPage - 1;
this.internalCurrentPage = this.getValidCurrentPage(newVal);
this.$emit('prev-click', this.internalCurrentPage);
this.emitChange();
},
@ -313,6 +314,7 @@ export default {
if (this.disabled) return;
const newVal = this.internalCurrentPage + 1;
this.internalCurrentPage = this.getValidCurrentPage(newVal);
this.$emit('next-click', this.internalCurrentPage);
this.emitChange();
},

View File

@ -322,6 +322,34 @@ describe('Pagination', () => {
}, 50);
});
it('event: prev and next click', done => {
vm = createVue({
template: `
<el-pagination
:total="100"
layout="sizes, prev, pager, next"
@prev-click="trigger = true"
@next-click="trigger = true"
:pageSize="10" />
`,
data() {
return { trigger: false };
}
}, true);
const prev = vm.$el.querySelector('.btn-prev');
const next = vm.$el.querySelector('.btn-next');
prev.click();
setTimeout(_ => {
expect(vm.trigger).to.false;
next.click();
setTimeout(_ => {
expect(vm.trigger).to.true;
done();
}, 50);
}, 50);
});
it('pageSize > total', () => {
vm = createVue({
template: `