pagination.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <template>
  2. <div id="pagination">
  3. <el-row type="flex" align="middle" style="padding-top:1rem">
  4. <el-col :span="24" :style="`text-align:${position};`">
  5. <el-pagination
  6. background
  7. layout=" total, prev, pager, next"
  8. :total="total"
  9. :page-size="limit"
  10. :current-page.sync="currentPage"
  11. @current-change="changePage"
  12. >
  13. </el-pagination>
  14. <!--
  15. :page-sizes="[5, 10, 15, 20, 50, 100]"
  16. @size-change="sizeChange"
  17. -->
  18. </el-col>
  19. </el-row>
  20. </div>
  21. </template>
  22. <script>
  23. import _ from 'lodash';
  24. export default {
  25. name: 'pagination',
  26. props: {
  27. position: { type: String, default: 'right' },
  28. total: { type: Number, default: 0 },
  29. limit: { type: Number, default: 10 },
  30. },
  31. components: {},
  32. data: () => {
  33. return {
  34. currentPage: 1,
  35. };
  36. },
  37. created() {},
  38. methods: {
  39. changePage(page) {
  40. this.$emit('query', { skip: (page - 1) * this.limit, limit: this.limit });
  41. },
  42. sizeChange(limit) {
  43. this.limit = limit;
  44. this.$emit('query', { skip: 0, limit: this.limit });
  45. },
  46. },
  47. };
  48. </script>
  49. <style lang="less" scoped></style>