Pagination.vue 1.8 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. @size-change="sizeChange"
  9. @current-change="currentChange"
  10. :total="pageTotal">
  11. </el-pagination>
  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: 10,
  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:10,
  50. pageLayout: null,
  51. colSpan:18
  52. };
  53. },
  54. created(){
  55. this.pageTotal = this.total;
  56. this.pageSizes = this.page_sizes;
  57. this.pageSize = this.page_size;
  58. this.pageLayout = this.layout;
  59. this.colSpan = this.span;
  60. },
  61. watch:{
  62. total(){
  63. this.pageTotal = this.total;
  64. },
  65. page_sizes(){
  66. this.pageSizes = this.page_sizes
  67. },
  68. page_size(){
  69. this.pageSize = this.page_size;
  70. },
  71. layout(){
  72. this.pageLayout = this.layout;
  73. },
  74. span(){
  75. this.colSpan = this.span;
  76. }
  77. },
  78. methods:{
  79. currentChange(currentPage){
  80. this.$emit('current-change', currentPage);
  81. },
  82. sizeChange(size){
  83. this.$emit('size-change', size);
  84. }
  85. },
  86. mounted(){
  87. }
  88. }
  89. </script>
  90. <style scoped>
  91. </style>