From 9a0f7e30c91e3970a81fda0f108fafdfdf86d74e Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Mon, 15 Aug 2016 13:35:16 +0800 Subject: [PATCH] update pagination and select event name --- examples/docs/pagination.md | 12 ++++++++---- examples/docs/select.md | 6 +++++- packages/pagination/src/pager.vue | 2 +- packages/pagination/src/pagination.js | 22 ++++++++++++++-------- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/examples/docs/pagination.md b/examples/docs/pagination.md index 58344f70e..c51d709b9 100644 --- a/examples/docs/pagination.md +++ b/examples/docs/pagination.md @@ -50,8 +50,8 @@ @@ -85,6 +85,10 @@ | current-page | 当前页数 | Number | | 0| | layout | 组件布局,子组件名用逗号分隔。| String | `prev`, `pager`, `next`, `jumper`, `slot`, `->`, `total` | 'prev, pager, next, jumper, slot, ->, total' | | page-sizes | 切换每页显示个数的子组件值 | Number[] | | [10, 20, 30, 40, 50, 100] | -| size-change | pageSize 改变时会触发的事件 | Function | | | -| current-change | currentPage 改变时会触发的事件 | Function | | | + +## 事件 +| 事件名称 | 说明 | 回调函数 | +|---------|--------|---------| +| sizechange | pageSize 改变时会触发 | `size` | +| currentchange | currentPage 改变时会触发 | `currentPage` | diff --git a/examples/docs/select.md b/examples/docs/select.md index c19cf4b6c..fcf62b84d 100644 --- a/examples/docs/select.md +++ b/examples/docs/select.md @@ -755,7 +755,11 @@ | remote | 是否为远程搜索 | boolean | | false | | remote-method | 远程搜索方法,当搜索关键字变化时会调用该方法,参数为目前的搜索关键字 | function | | | | loading | 是否正在从远程获取数据 | boolean | | false | -| change | value 发生变化时的回调函数,参数为 value 的值 | function | | | + +### el-select 事件 +| 事件名称 | 说明 | 回调参数 | +|---------|---------|---------| +| change | value 发生变化| `value` | ### el-option-group | 参数 | 说明 | 类型 | 可选值 | 默认值 | diff --git a/packages/pagination/src/pager.vue b/packages/pagination/src/pager.vue index a5a7dd004..879da2ea0 100644 --- a/packages/pagination/src/pager.vue +++ b/packages/pagination/src/pager.vue @@ -71,7 +71,7 @@ } if (newPage !== currentPage) { - this.$emit('currentChange', newPage); + this.$emit('currentchange', newPage); } } }, diff --git a/packages/pagination/src/pagination.js b/packages/pagination/src/pagination.js index 82a7b56d2..a4c0cf6e0 100644 --- a/packages/pagination/src/pagination.js +++ b/packages/pagination/src/pagination.js @@ -49,7 +49,7 @@ export default { const TEMPLATE_MAP = { prev: , jumper: , - pager: , + pager: , next: , sizes: , slot: , @@ -114,6 +114,12 @@ export default { }, Sizes: { + created() { + if (Array.isArray(this.$parent.pageSizes)) { + this.$parent.internalPageSize = this.$parent.pageSizes[0]; + } + }, + render(h) { return ( @@ -144,7 +150,7 @@ export default { handleChange(val) { if (val !== this.$parent.internalPageSize) { this.$parent.internalPageSize = val = parseInt(val, 10); - this.$parent.$emit('size-change', val); + this.$parent.$emit('sizechange', val); } } } @@ -167,7 +173,7 @@ export default { this.$parent.internalCurrentPage = this.$parent.getValidCurrentPage(target.value); if (target.value !== this.oldValue && Number(target.value) === this.$parent.internalCurrentPage) { - this.$parent.$emit('current-change', this.$parent.internalCurrentPage); + this.$parent.$emit('currentchange', this.$parent.internalCurrentPage); } this.oldValue = null; @@ -209,7 +215,7 @@ export default { methods: { handleCurrentChange(val) { this.internalCurrentPage = this.getValidCurrentPage(val); - this.$emit('current-change', this.internalCurrentPage); + this.$emit('currentchange', this.internalCurrentPage); }, prev() { @@ -218,7 +224,7 @@ export default { this.internalCurrentPage = this.getValidCurrentPage(newVal); if (this.internalCurrentPage !== oldPage) { - this.$emit('current-change', this.internalCurrentPage); + this.$emit('currentchange', this.internalCurrentPage); } }, @@ -228,7 +234,7 @@ export default { this.internalCurrentPage = this.getValidCurrentPage(newVal); if (this.internalCurrentPage !== oldPage) { - this.$emit('current-change', this.internalCurrentPage); + this.$emit('currentchange', this.internalCurrentPage); } }, @@ -238,7 +244,7 @@ export default { this.internalCurrentPage = this.getValidCurrentPage(newVal); if (this.internalCurrentPage !== oldPage) { - this.$emit('current-change', this.internalCurrentPage); + this.$emit('currentchange', this.internalCurrentPage); } }, @@ -248,7 +254,7 @@ export default { this.internalCurrentPage = this.getValidCurrentPage(newVal); if (this.internalCurrentPage !== oldPage) { - this.$emit('current-change', this.internalCurrentPage); + this.$emit('currentchange', this.internalCurrentPage); } },