Created
October 20, 2017 06:41
-
-
Save wisetc/7b2a4dfe6433392032b968b29473416a to your computer and use it in GitHub Desktop.
vue mixins pagination based on element-ui.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<el-pagination | |
v-if="pagination.total > 10" | |
@size-change="handleSizeChange" | |
@current-change="handleCurrentChange" | |
:current-page="pagination.current" | |
:page-sizes="pagination.sizes" | |
:page-size="pagination.size" | |
layout="sizes, prev, pager, next" | |
:total="pagination.total" | |
style="margin-top:8px; float:right;"> | |
</el-pagination> | |
<div style="clear:both;"></div> | |
</div> | |
</template> | |
<script> | |
export default { | |
data() { | |
return { | |
pagination: { | |
current: 1, | |
sizes: [5, 10, 20, 50], | |
size: 10, | |
total: null | |
} | |
} | |
}, | |
methods: { | |
loadData() {}, | |
handleSizeChange(val) { | |
this.pagination.size = val | |
this.loadData() | |
}, | |
handleCurrentChange(val) { | |
this.pagination.current = val | |
this.loadData() | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment