mirror of
https://gitee.com/ElemeFE/element.git
synced 2024-11-30 03:07:36 +08:00
Pagination: fix current-change emit too many.
This commit is contained in:
parent
72a66e8c48
commit
28958fa051
@ -186,7 +186,7 @@
|
|||||||
| small | 是否使用小型分页样式 | Boolean | — | false |
|
| small | 是否使用小型分页样式 | Boolean | — | false |
|
||||||
| page-size | 每页显示条目个数 | Number | — | 10 |
|
| page-size | 每页显示条目个数 | Number | — | 10 |
|
||||||
| total | 总条目数 | Number | — | - |
|
| total | 总条目数 | Number | — | - |
|
||||||
| page-count | 总页数,total 和 page-count 设置任意一个就可以达到显示页码的功能如果要支持 page-sizes 的更改,则需要使用 total 属性;如果要支持 page-sizes 的更改,则需要使用 total 属性 | Number | — | - |
|
| page-count | 总页数,total 和 page-count 设置任意一个就可以达到显示页码的功能;如果要支持 page-sizes 的更改,则需要使用 total 属性 | Number | — | - |
|
||||||
| current-page | 当前页数 | Number | — | 1 |
|
| current-page | 当前页数 | Number | — | 1 |
|
||||||
| layout | 组件布局,子组件名用逗号分隔| String | `sizes`, `prev`, `pager`, `next`, `jumper`, `->`, `total` | 'prev, pager, next, jumper, ->, total' |
|
| layout | 组件布局,子组件名用逗号分隔| String | `sizes`, `prev`, `pager`, `next`, `jumper`, `->`, `total` | 'prev, pager, next, jumper, ->, total' |
|
||||||
| page-sizes | 每页显示个数选择器的选项设置 | Number[] | — | [10, 20, 30, 40, 50, 100] |
|
| page-sizes | 每页显示个数选择器的选项设置 | Number[] | — | [10, 20, 30, 40, 50, 100] |
|
||||||
|
@ -174,8 +174,11 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleChange({ target }) {
|
handleChange({ target }) {
|
||||||
|
const oldPage = this.$parent.internalCurrentPage;
|
||||||
this.$parent.internalCurrentPage = this.$parent.getValidCurrentPage(target.value);
|
this.$parent.internalCurrentPage = this.$parent.getValidCurrentPage(target.value);
|
||||||
this.$parent.$emit('current-change', this.$parent.internalCurrentPage);
|
if (oldPage !== this.$parent.internalCurrentPage) {
|
||||||
|
this.$parent.$emit('current-change', this.$parent.internalCurrentPage);
|
||||||
|
}
|
||||||
this.oldValue = null;
|
this.oldValue = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -225,8 +228,11 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleCurrentChange(val) {
|
handleCurrentChange(val) {
|
||||||
|
const oldPage = this.internalCurrentPage;
|
||||||
this.internalCurrentPage = this.getValidCurrentPage(val);
|
this.internalCurrentPage = this.getValidCurrentPage(val);
|
||||||
this.$emit('current-change', this.internalCurrentPage);
|
if (oldPage !== this.internalCurrentPage) {
|
||||||
|
this.$emit('current-change', this.internalCurrentPage);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
prev() {
|
prev() {
|
||||||
@ -289,11 +295,13 @@ export default {
|
|||||||
watch: {
|
watch: {
|
||||||
internalPageCount(newVal) {
|
internalPageCount(newVal) {
|
||||||
/* istanbul ignore if */
|
/* istanbul ignore if */
|
||||||
if (newVal > 0 && this.internalCurrentPage === 0) {
|
const oldPage = this.internalCurrentPage;
|
||||||
|
if (newVal > 0 && oldPage === 0) {
|
||||||
this.internalCurrentPage = 1;
|
this.internalCurrentPage = 1;
|
||||||
this.$emit('current-change', 1);
|
} else if (oldPage > newVal) {
|
||||||
} else if (this.internalCurrentPage > newVal) {
|
|
||||||
this.internalCurrentPage = newVal === 0 ? 1 : newVal;
|
this.internalCurrentPage = newVal === 0 ? 1 : newVal;
|
||||||
|
}
|
||||||
|
if (oldPage !== this.internalCurrentPage) {
|
||||||
this.$emit('current-change', this.internalCurrentPage);
|
this.$emit('current-change', this.internalCurrentPage);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -142,7 +142,7 @@ describe('Pagination', () => {
|
|||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return { page: 0 };
|
return { page: 1 };
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
const input = vm.$el.querySelector('.el-pagination__jump input');
|
const input = vm.$el.querySelector('.el-pagination__jump input');
|
||||||
@ -228,7 +228,7 @@ describe('Pagination', () => {
|
|||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return { page: 0 };
|
return { page: 1 };
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const input = vm.$el.querySelector('.el-pagination__jump input');
|
const input = vm.$el.querySelector('.el-pagination__jump input');
|
||||||
|
Loading…
Reference in New Issue
Block a user