Pagination.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <!-- 新闻详情页 页码 -->
  3. <div class="pagination">
  4. <el-pagination size="small" background layout="prev, pager, next" :total="props.total" class="mt-4" prev-text="上一页"
  5. next-text="下一页" @change="change" />
  6. </div>
  7. </template>
  8. <script setup>
  9. import { ElPagination } from 'element-plus'
  10. // 当前页码
  11. const emit = defineEmits(['sendData'])
  12. let page = useState("page", () => 1)
  13. const props = defineProps({
  14. total: Number
  15. });
  16. let change = (value) => {
  17. console.log("当前页码",value);
  18. page.value = value
  19. console.log(page.value);
  20. const data = { value: page.value }
  21. // 触发自定义事件
  22. emit('sendData', data)
  23. }
  24. </script>
  25. <style lang="less" scoped>
  26. .pagination {
  27. width: 508px;
  28. height: 34px;
  29. margin: 0 auto;
  30. // 鼠标移入后字体颜色
  31. .el-pagination::v-deep :hover {
  32. color: #139609;
  33. }
  34. .el-pagination.is-background::v-deep .btn-next,
  35. .el-pagination.is-background::v-deep .btn-prev {
  36. width: 70px;
  37. height: 34px;
  38. margin: 0px 10px;
  39. border-radius: 4px;
  40. }
  41. .el-pagination.is-background::v-deep .el-pager li {
  42. margin: 0px 10px;
  43. width: 38px;
  44. height: 34px;
  45. border-radius: 4px;
  46. }
  47. .el-pagination.is-background::v-deep .btn-next.is-active,
  48. .el-pagination.is-background::v-deep .btn-prev.is-active,
  49. .el-pagination.is-background::v-deep .el-pager li.is-active {
  50. background-color: #028e21;
  51. color: #fff;
  52. }
  53. }
  54. </style>