myPagination.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <!--
  2. props:{
  3. size: 当前页的页数,
  4. sizes: 下拉的条数,
  5. total: 总条数,
  6. currentPage: 当前页
  7. }
  8. @change 发生改变
  9. -->
  10. <template>
  11. <div class="block">
  12. <el-pagination
  13. @size-change="handleSizeChange"
  14. @current-change="handleCurrentChange"
  15. :current-page.sync="page.currentPage"
  16. :page-sizes="page.sizes"
  17. :page-size="page.size"
  18. :layout=" isSmall ? 'total, sizes, prev, pager, next, jumper' : 'prev, pager, next'"
  19. :total="page.total">
  20. </el-pagination>
  21. </div>
  22. </template>
  23. <script>
  24. export default {
  25. name: "pagination",
  26. props: {
  27. page: {
  28. type: Object
  29. },
  30. isSmall:{
  31. type:Boolean,
  32. default: true
  33. }
  34. },
  35. methods: {
  36. //当前条数发生改变
  37. handleSizeChange(val) {
  38. this.page.size = val;
  39. this.change()
  40. },
  41. //当前页发生改变
  42. handleCurrentChange(val) {
  43. this.page.currentPage = val;
  44. this.change()
  45. },
  46. //发生改变
  47. change() {
  48. this.$emit("change");
  49. }
  50. }
  51. };
  52. </script>
  53. <style>
  54. .el-pagination button, .el-pagination span:not([class*=suffix]) {
  55. vertical-align: middle;
  56. }
  57. .block{
  58. /* margin-top: 5px; */
  59. }
  60. </style>