Pagination.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <template>
  2. <el-pagination background
  3. @size-change="sizeChangeHandle"
  4. @current-change="currentChangeHandle"
  5. :current-page="paginations.pageNo"
  6. :total="paginations.total"
  7. :page-size="paginations.pageSize"
  8. :page-sizes="pages"
  9. layout="total,sizes,prev,pager,next,jumper">
  10. </el-pagination>
  11. </template>
  12. <script>
  13. export default {
  14. name: 'paginations',
  15. props: ['paginations'],
  16. data () {
  17. return {
  18. pages: [5, 10, 20, 50, 100]
  19. }
  20. },
  21. created () {
  22. this.$config.paginationParams = {
  23. pageNo: 1,
  24. pageSize: 5,
  25. total: 0,
  26. pages: [5, 10, 20, 50, 100]
  27. }
  28. },
  29. methods: {
  30. //当前页
  31. currentChangeHandle (val) {
  32. this.paginations.pageNo = val
  33. if (this.paginations.total) {//有数据才发送请求
  34. this.$emit('sendPaginations', val)
  35. }
  36. },
  37. //切换条数
  38. sizeChangeHandle (val) {
  39. this.paginations.pageSize = val
  40. //能通过this.paginations获取props属性
  41. if (this.paginations.total) {//有数据才发送请求
  42. this.$emit('sendPaginations', val)
  43. }
  44. }
  45. }
  46. }
  47. </script>