Skip to content

Commit 2ff8ba0

Browse files
committed
feat: update pagination
1 parent a760a10 commit 2ff8ba0

File tree

5 files changed

+16
-18
lines changed

5 files changed

+16
-18
lines changed

components/pagination/Pagination.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export default {
113113
...this.getIconsProps(prefixCls),
114114
selectComponentClass: isSmall ? MiniSelect : VcSelect,
115115
locale: { ...contextLocale, ...customLocale },
116-
buildOptionText: buildOptionText || this.$slots.buildOptionText?.(),
116+
buildOptionText: buildOptionText || this.$slots.buildOptionText,
117117
...this.$attrs,
118118
class: classNames({ mini: isSmall }, this.$attrs.class),
119119
};
@@ -126,7 +126,7 @@ export default {
126126
<LocaleReceiver
127127
componentName="Pagination"
128128
defaultLocale={enUS}
129-
slots={{ default: this.renderPagination }}
129+
children={this.renderPagination}
130130
></LocaleReceiver>
131131
);
132132
},

components/pagination/index.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import Pagination from './Pagination';
2-
import Base from '../base';
32

43
export { PaginationProps, PaginationConfig } from './Pagination';
54

65
/* istanbul ignore next */
76
Pagination.install = function(app) {
8-
app.use(Base);
97
app.component(Pagination.name, Pagination);
108
};
119

components/vc-pagination/Pagination.jsx

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PropTypes from '../_util/vue-types';
22
import BaseMixin from '../_util/BaseMixin';
3-
import { hasProp, getOptionProps, getComponent } from '../_util/props-util';
3+
import { hasProp, getOptionProps, getComponent, splitAttrs } from '../_util/props-util';
44
import Pager from './Pager';
55
import Options from './Options';
66
import LOCALE from './locale/zh_CN';
@@ -30,10 +30,6 @@ export default {
3030
name: 'Pagination',
3131
mixins: [BaseMixin],
3232
inheritAttrs: false,
33-
model: {
34-
prop: 'current',
35-
event: 'change.current',
36-
},
3733
props: {
3834
disabled: PropTypes.bool,
3935
prefixCls: PropTypes.string.def('rc-pagination'),
@@ -241,7 +237,7 @@ export default {
241237
this.$emit('update:pageSize', size);
242238
this.$emit('showSizeChange', current, size);
243239
if (current !== preCurrent) {
244-
this.$emit('change.current', current, size);
240+
this.$emit('update:current', current);
245241
}
246242
},
247243
handleChange(p) {
@@ -262,7 +258,7 @@ export default {
262258
}
263259
// this.$emit('input', page)
264260
this.$emit('change', page, this.statePageSize);
265-
this.$emit('change.current', page, this.statePageSize);
261+
this.$emit('update:current', page);
266262
return page;
267263
}
268264
return this.stateCurrent;
@@ -314,7 +310,7 @@ export default {
314310
},
315311
render() {
316312
const { prefixCls, disabled } = this.$props;
317-
313+
const { class: className, ...restAttrs } = splitAttrs(this.$attrs).extraAttrs;
318314
// When hideOnSinglePage is true and there is only 1 page, hide the pager
319315
if (this.hideOnSinglePage === true && this.total <= this.statePageSize) {
320316
return null;
@@ -363,7 +359,7 @@ export default {
363359
const hasNext = this.hasNext();
364360

365361
return (
366-
<ul class={classNames(`${prefixCls} ${prefixCls}-simple`, this.$attrs.class)}>
362+
<ul class={classNames(`${prefixCls} ${prefixCls}-simple`, className)} {...restAttrs}>
367363
<li
368364
title={this.showTitle ? locale.prev_page : null}
369365
onClick={this.prev}
@@ -579,14 +575,16 @@ export default {
579575
}
580576
const prevDisabled = !this.hasPrev() || !allPages;
581577
const nextDisabled = !this.hasNext() || !allPages;
582-
const buildOptionText = this.buildOptionText || this.$slots.buildOptionText?.();
583-
const { class: _cls, style } = this.$attrs;
578+
const buildOptionText = this.buildOptionText || this.$slots.buildOptionText;
584579
return (
585580
<ul
586581
unselectable="unselectable"
587582
ref="paginationNode"
588-
style={style}
589-
class={classNames({ [`${prefixCls}`]: true, [`${prefixCls}-disabled`]: disabled }, _cls)}
583+
{...restAttrs}
584+
class={classNames(
585+
{ [`${prefixCls}`]: true, [`${prefixCls}-disabled`]: disabled },
586+
className,
587+
)}
590588
>
591589
{totalText}
592590
<li

examples/App.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</div>
55
</template>
66
<script>
7-
import demo from '../antdv-demo/docs/form-model/demo/custom-validation';
7+
import demo from '../antdv-demo/docs/pagination/demo/custom-changer';
88
99
export default {
1010
components: {

examples/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
Switch,
2323
Checkbox,
2424
Cascader,
25+
Pagination,
2526
notification,
2627
message,
2728
} from 'ant-design-vue';
@@ -44,6 +45,7 @@ app
4445
.component('api', { ...basic })
4546
.component('CN', { ...basic })
4647
.component('US', { ...basic })
48+
.use(Pagination)
4749
.use(Select)
4850
.use(Spin)
4951
.use(Upload)

0 commit comments

Comments
 (0)