//导入
<pagination
:total='page.total'
:page='page.current'
:limit='page.size'
@update:limit='updatelimit'
@update:page='updatepage'
@pagination='pagination'></pagination>
import Pagination from "../comments/Pagination/index"
//data
//分页
page:{
total:10,
current:1,
size:10,
},
//方法
//获取接口列表
getinterface(val){
request('/md/conf/data/dataInfo/selectPage', val, (flag, data, res) => {
this.page={
total:data.total,
current:data.current,
size:data.size
}
}, () => {
});
},
//分页条数
pagination(val){
this.page.current=val.page
this.page.size=val.limit
this.getinterface({size:this.page.size,current:this.page.current})
},
//条数回调
updatelimit(val){
this.page.size=val
// this.getinterface({size:this.page.size,current:this.page.current})
},
//页数回调
updatepage(val){
this.page.current=val
// this.getinterface({size:this.page.size,current:this.page.current})
},
//分页器
<template>
<div :class="{'hidden':hidden}" class="pagination-container">
<el-pagination
:background="background"
:current-page.sync="currentPage"
:page-size.sync="pageSize"
:layout="layout"
:page-sizes="pageSizes"
:total="total"
v-bind="$attrs"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"/>
</div>
</template>
<script>
export default {
name: 'Pagination',
props: {
total: {
required: true,
type: Number
},
page: {
type: Number,
default: 1
},
limit: {
type: Number,
default: 20
},
pageSizes: {
type: Array,
default() {
return [10, 20, 30, 50]
}
},
layout: {
type: String,
default: 'total, sizes, prev, pager, next, jumper'
},
background: {
type: Boolean,
default: true
},
autoScroll: {
type: Boolean,
default: true
},
hidden: {
type: Boolean,
default: false
}
},
computed: {
currentPage: {
get() {
return this.page
},
set(val) {
this.$emit('update:page', val)
}
},
pageSize: {
get() {
return this.limit
},
set(val) {
this.$emit('update:limit', val)
}
}
},
methods: {
// 每条页数
handleSizeChange(val) {
this.$emit('pagination', { page: this.currentPage, limit: val })
},
// 当前页
handleCurrentChange(val) {
this.$emit('pagination', { page: val, limit: this.pageSize })
}
}
}
</script>
<style scoped>
.pagination-container {
/* background: #fff; */
padding: 0 16px 32px;
}
.pagination-container.hidden {
display: none;
}
.el-pagination {
text-align: center;
}
</style>
网友评论