pagination .vue 988 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <template>
  2. <el-pagination
  3. class="pagination"
  4. @size-change="handleSizeChange"
  5. @current-change="handleCurrentChange"
  6. :current-page="page"
  7. :page-sizes="[10,20,50,100]"
  8. :page-size="size"
  9. layout="total, sizes, prev, pager, next, jumper"
  10. :total="total">
  11. </el-pagination>
  12. </template>
  13. <script>
  14. export default {
  15. props: {
  16. total: { type: Number, default: 0 }
  17. },
  18. data () {
  19. return {
  20. page: 0,
  21. size: 10
  22. }
  23. },
  24. methods: {
  25. resetpage (val) {
  26. if (val < 0) {
  27. this.page = 0
  28. } else {
  29. this.page = val
  30. }
  31. },
  32. handleSizeChange (val) {
  33. this.size = val
  34. this.handleChange()
  35. },
  36. handleCurrentChange (val) {
  37. this.page = val
  38. this.handleChange()
  39. },
  40. handleChange () {
  41. this.$emit('handlechange', { page: this.page, size: this.size })
  42. }
  43. },
  44. mounted () {}
  45. }
  46. </script>
  47. <style lang="less" scoped>
  48. .pagination {
  49. margin-left: 1%;
  50. margin-top: 20px;
  51. }
  52. </style>