ant-design-vue/components/pagination/Pager.vue

48 lines
1020 B
Vue
Raw Normal View History

2017-11-07 11:57:16 +08:00
<script>
export default {
name: 'Page',
props: {
rootPrefixCls: String,
page: Number,
active: Boolean,
showTitle: Boolean,
2017-12-20 10:56:21 +08:00
itemRender: {
type: Function,
default: () => {},
},
2017-11-07 11:57:16 +08:00
},
computed: {
classes () {
const prefixCls = `${this.rootPrefixCls}-item`
let cls = `${prefixCls} ${prefixCls}-${this.page}`
if (this.active) {
cls = `${cls} ${prefixCls}-active`
}
if (this.className) {
cls = `${cls} ${this.className}`
}
return cls
},
},
methods: {
handleClick () {
this.$emit('click', this.page)
},
handleKeyPress (event) {
this.$emit('keyPress', event, this.handleClick, this.page)
},
},
2017-12-20 10:56:21 +08:00
render () {
return (
<li
class={this.classes}
onClick={this.handleClick}
onKeypress={this.handleKeyPress}
title={this.showTitle ? this.page : null}>
{this.itemRender(this.page, 'page', <a>{this.page}</a>)}
</li>
)
},
2017-11-07 11:57:16 +08:00
}
</script>