2019-01-12 11:33:27 +08:00
|
|
|
import PropTypes from '../_util/vue-types';
|
2020-03-07 19:45:13 +08:00
|
|
|
import classNames from 'classnames';
|
2018-03-05 19:06:44 +08:00
|
|
|
|
2017-11-07 11:57:16 +08:00
|
|
|
export default {
|
2018-05-26 22:47:19 +08:00
|
|
|
name: 'Pager',
|
2017-11-07 11:57:16 +08:00
|
|
|
props: {
|
2018-03-05 19:06:44 +08:00
|
|
|
rootPrefixCls: PropTypes.string,
|
|
|
|
page: PropTypes.number,
|
|
|
|
active: PropTypes.bool,
|
|
|
|
last: PropTypes.bool,
|
|
|
|
locale: PropTypes.object,
|
|
|
|
showTitle: PropTypes.bool,
|
2017-12-20 10:56:21 +08:00
|
|
|
itemRender: {
|
|
|
|
type: Function,
|
|
|
|
default: () => {},
|
|
|
|
},
|
2017-11-07 11:57:16 +08:00
|
|
|
},
|
|
|
|
methods: {
|
2019-01-12 11:33:27 +08:00
|
|
|
handleClick() {
|
|
|
|
this.$emit('click', this.page);
|
2017-11-07 11:57:16 +08:00
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
handleKeyPress(event) {
|
|
|
|
this.$emit('keypress', event, this.handleClick, this.page);
|
2017-11-07 11:57:16 +08:00
|
|
|
},
|
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
render() {
|
2020-03-07 19:45:13 +08:00
|
|
|
const props = this.$props;
|
|
|
|
const prefixCls = `${props.rootPrefixCls}-item`;
|
|
|
|
const cls = classNames(prefixCls, `${prefixCls}-${props.page}`, {
|
|
|
|
[`${prefixCls}-active`]: props.active,
|
|
|
|
[`${prefixCls}-disabled`]: !props.page,
|
|
|
|
});
|
2019-01-01 21:19:50 +08:00
|
|
|
|
2017-12-20 10:56:21 +08:00
|
|
|
return (
|
|
|
|
<li
|
2018-03-05 19:06:44 +08:00
|
|
|
class={cls}
|
2017-12-20 10:56:21 +08:00
|
|
|
onClick={this.handleClick}
|
|
|
|
onKeypress={this.handleKeyPress}
|
2018-03-05 19:06:44 +08:00
|
|
|
title={this.showTitle ? this.page : null}
|
2019-01-12 11:33:27 +08:00
|
|
|
tabIndex="0"
|
2018-03-05 19:06:44 +08:00
|
|
|
>
|
2017-12-20 10:56:21 +08:00
|
|
|
{this.itemRender(this.page, 'page', <a>{this.page}</a>)}
|
|
|
|
</li>
|
2019-01-12 11:33:27 +08:00
|
|
|
);
|
2017-12-20 10:56:21 +08:00
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
};
|