mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-04 13:08:48 +08:00
57 lines
1.3 KiB
Vue
57 lines
1.3 KiB
Vue
import PropTypes from '../_util/vue-types';
|
|
import classNames from 'classnames';
|
|
import BaseMixin from '../_util/BaseMixin';
|
|
|
|
export default {
|
|
name: 'Pager',
|
|
mixins: [BaseMixin],
|
|
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({ page: this.page, type: 'page', originalElement: <a>{this.page}</a> })}
|
|
</li>
|
|
);
|
|
},
|
|
};
|