index.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <div style="float: right;">
  3. <el-pagination
  4. :page-sizes="pageSizes"
  5. :page-size="pageSize"
  6. :background="background"
  7. :layout="pageLayout"
  8. :total="pageTotal"
  9. @size-change="sizeChange"
  10. @current-change="currentChange"
  11. />
  12. </div>
  13. </template>
  14. <script>
  15. export default {
  16. name: 'Pagination',
  17. props: {
  18. total: {
  19. default: 0,
  20. type: Number
  21. },
  22. page_sizes: {
  23. default: function() {
  24. return [1, 2, 5, 10, 20]
  25. },
  26. type: Array
  27. },
  28. page_size: {
  29. default: 20,
  30. type: Number
  31. },
  32. layout: {
  33. default: 'total, sizes, prev, pager, next, jumper',
  34. type: String
  35. },
  36. page: {
  37. default: 1,
  38. type: Number
  39. },
  40. background: {
  41. default: true,
  42. type: Boolean
  43. }
  44. },
  45. data() {
  46. return {
  47. pageTotal: 1,
  48. pageSizes: null,
  49. pageSize: 20,
  50. pageLayout: null,
  51. colSpan: 18
  52. }
  53. },
  54. watch: {
  55. total() {
  56. this.pageTotal = this.total
  57. },
  58. page_sizes() {
  59. this.pageSizes = this.page_sizes
  60. },
  61. page_size() {
  62. this.pageSize = this.page_size
  63. },
  64. layout() {
  65. this.pageLayout = this.layout
  66. },
  67. span() {
  68. this.colSpan = this.span
  69. }
  70. },
  71. created() {
  72. this.pageTotal = this.total
  73. this.pageSizes = this.page_sizes
  74. this.pageSize = this.page_size
  75. this.pageLayout = this.layout
  76. this.colSpan = this.span
  77. },
  78. mounted() {
  79. },
  80. methods: {
  81. currentChange(currentPage) {
  82. this.$emit('current-change', currentPage)
  83. },
  84. sizeChange(size) {
  85. this.$emit('size-change', size)
  86. }
  87. }
  88. }
  89. </script>
  90. <style scoped>
  91. </style>