Pagination.vue 931 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <div>
  3. <el-pagination
  4. v-if="show"
  5. background
  6. :page-size.sync="pageSize"
  7. :pager-count="11"
  8. layout="prev,pager,next,total"
  9. @current-change="onChange"
  10. :total="count">
  11. </el-pagination>
  12. </div>
  13. </template>
  14. <script>
  15. import {paginationConfig} from '@/api/CONST'
  16. export default{
  17. name: 'Pagination',
  18. props:{
  19. total: {
  20. type: [String, Number],
  21. default:0
  22. }
  23. },
  24. data(){
  25. return{
  26. show:true,
  27. pageSize: paginationConfig.pageSize,
  28. count: 0
  29. }
  30. },
  31. created(){
  32. },
  33. methods:{
  34. onChange(index){
  35. const json = {
  36. pageNo: index,
  37. pageSize: paginationConfig.pageSize
  38. }
  39. this.$emit('change',json)
  40. }
  41. },
  42. watch:{
  43. total(newVal,oldVal){
  44. this.show = false
  45. this.count = newVal
  46. const timer = setTimeout(()=>{
  47. this.show = true
  48. clearTimeout(timer)
  49. },10)
  50. }
  51. }
  52. }
  53. </script>
  54. <style>
  55. </style>