Pagination.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <!-- 新闻详情页 页码 -->
  3. <div class="pagination">
  4. <el-pagination size="small" background layout="prev, pager, next" :total="props.total" class="mt-4"
  5. prev-text="上一页" 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. display: flex;
  28. justify-content: center;
  29. width: 1200px;
  30. height: 34px;
  31. margin: 0;
  32. // 鼠标移入后字体颜色
  33. .el-pagination::v-deep :hover {
  34. color: #139609;
  35. }
  36. .el-pagination.is-background::v-deep .btn-next,
  37. .el-pagination.is-background::v-deep .btn-prev {
  38. width: 70px;
  39. height: 34px;
  40. margin: 0px 10px;
  41. border-radius: 4px;
  42. }
  43. .el-pagination.is-background::v-deep .el-pager li {
  44. margin: 0px 10px;
  45. width: 38px;
  46. height: 34px;
  47. border-radius: 4px;
  48. }
  49. .el-pagination.is-background::v-deep .btn-next.is-active,
  50. .el-pagination.is-background::v-deep .btn-prev.is-active,
  51. .el-pagination.is-background::v-deep .el-pager li.is-active {
  52. background-color: #028e21;
  53. color: #fff;
  54. }
  55. }
  56. </style>