forked from vueComponent/ant-design-vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPager.jsx
54 lines (52 loc) · 1.23 KB
/
Pager.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import PropTypes from '../_util/vue-types';
import classNames from 'classnames';
export default {
name: 'Pager',
inheritAttrs: false,
props: {
rootPrefixCls: PropTypes.string,
page: PropTypes.number,
active: PropTypes.bool,
last: PropTypes.bool,
locale: PropTypes.object,
showTitle: PropTypes.bool,
itemRender: {
type: Function,
default: () => {},
},
},
methods: {
handleClick() {
this.$emit('click', this.page);
},
handleKeyPress(event) {
this.$emit('keypress', event, this.handleClick, this.page);
},
},
render() {
const { class: _cls, style } = this.$attrs;
const props = this.$props;
const prefixCls = `${props.rootPrefixCls}-item`;
const cls = classNames(
prefixCls,
`${prefixCls}-${props.page}`,
{
[`${prefixCls}-active`]: props.active,
[`${prefixCls}-disabled`]: !props.page,
},
_cls,
);
return (
<li
onClick={this.handleClick}
onKeypress={this.handleKeyPress}
title={this.showTitle ? this.page : null}
tabIndex="0"
class={cls}
style={style}
>
{this.itemRender(this.page, 'page', <a>{this.page}</a>)}
</li>
);
},
};