index.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <div :class="{ hidden: hidden }" class="pagination-container">
  3. <el-pagination
  4. :background="background"
  5. :current-page.sync="currentPage"
  6. :page-size.sync="pageSize"
  7. :layout="layout"
  8. :page-sizes="pageSizes"
  9. :total="total"
  10. v-bind="$attrs"
  11. @size-change="handleSizeChange"
  12. @current-change="handleCurrentChange"
  13. />
  14. </div>
  15. </template>
  16. <script>
  17. export default {
  18. name: 'Pagination',
  19. props: {
  20. total: {
  21. required: true,
  22. type: Number
  23. },
  24. current: {
  25. type: Number,
  26. default: 1
  27. },
  28. size: {
  29. type: Number,
  30. default: 10
  31. },
  32. pageSizes: {
  33. type: Array,
  34. default() {
  35. return [10, 20, 30, 50];
  36. }
  37. },
  38. layout: {
  39. type: String,
  40. default: 'total, sizes, prev, pager, next, jumper'
  41. },
  42. background: {
  43. type: Boolean,
  44. default: true
  45. },
  46. autoScroll: {
  47. type: Boolean,
  48. default: true
  49. },
  50. hidden: {
  51. type: Boolean,
  52. default: false
  53. }
  54. },
  55. computed: {
  56. currentPage: {
  57. get() {
  58. return this.current;
  59. },
  60. set(val) {
  61. this.$emit('update:current', val);
  62. }
  63. },
  64. pageSize: {
  65. get() {
  66. return this.size;
  67. },
  68. set(val) {
  69. this.$emit('update:size', val);
  70. }
  71. }
  72. },
  73. methods: {
  74. handleSizeChange(val) {
  75. this.$emit('pagination', { current: this.currentPage, size: val });
  76. },
  77. handleCurrentChange(val) {
  78. this.$emit('pagination', { current: val, size: this.pageSize });
  79. }
  80. }
  81. };
  82. </script>
  83. <style scoped>
  84. .pagination-container {
  85. background: #fff;
  86. /*padding: 5px 5px;*/
  87. }
  88. .el-pagination {
  89. text-align: left !important;
  90. }
  91. .pagination-container.hidden {
  92. display: none;
  93. }
  94. </style>