SmallSwiper.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <div class="swiper" v-if="swiperData.length > 0">
  3. <el-carousel :interval="5000" arrow="always" height="214px" indicator-class="custom-indicator">
  4. <el-carousel-item v-for="item in swiperData" :key="item">
  5. <img :src="item.imgurl" :alt="item.title">
  6. <span>
  7. <NuxtLink :to="{path:`/newsDetail/${item.id}`,query:{listId:routeId,listName:routeName}}" :title="item.title">{{item.title}}</NuxtLink>
  8. </span>
  9. </el-carousel-item>
  10. </el-carousel>
  11. </div>
  12. </template>
  13. <script setup>
  14. import { ElCarousel, ElCarouselItem } from 'element-plus'
  15. const props = defineProps({
  16. swiperData: Array
  17. });
  18. </script>
  19. <style lang="less" scoped>
  20. .swiper {
  21. width: 380px;
  22. height: 214px;
  23. position: relative;
  24. img {
  25. width: 380px;
  26. height: 214px;
  27. }
  28. span {
  29. display: inline-block;
  30. width: 370px;
  31. height: 30px;
  32. line-height: 30px;
  33. padding-left: 13px;
  34. position: absolute;
  35. top: 0;
  36. left: 0;
  37. font-family: PingFang SC, PingFang SC;
  38. font-weight: 500;
  39. font-size: 20px;
  40. color: #FFFFFF;
  41. background-color: rgba(0, 0, 0, 0.5);
  42. white-space: nowrap; /* 禁止换行 */
  43. overflow: hidden; /* 隐藏超出部分 */
  44. text-overflow: ellipsis; /* 超出部分显示省略号 */
  45. a{
  46. color: #fff;
  47. }
  48. }
  49. }
  50. .el-carousel {
  51. /deep/.el-carousel__arrow i {
  52. font-size: 30px !important;
  53. }
  54. /deep/.el-carousel__arrow--left {
  55. left: 16px;
  56. width: 35px;
  57. height: 57px;
  58. color: #616358;
  59. background: #dcdedc;
  60. position: absolute;
  61. left: 0px;
  62. border: none;
  63. border-radius: 0;
  64. }
  65. /deep/.el-carousel__arrow--right {
  66. right: 16px;
  67. width: 35px;
  68. height: 57px;
  69. color: #616358;
  70. background: #dcdedc;
  71. position: absolute;
  72. right: 0;
  73. border: none;
  74. border-radius: 0;
  75. }
  76. /deep/ .el-carousel__indicators {
  77. // 指示器
  78. left: unset;
  79. transform: unset;
  80. right: 41%;
  81. }
  82. /deep/ .el-carousel__button {
  83. // 指示器按钮
  84. width: 10px;
  85. height: 10px;
  86. border: none;
  87. border-radius: 50%;
  88. border: 1px solid #fff;
  89. background-color: transparent;
  90. }
  91. /deep/ .is-active .el-carousel__button {
  92. // 指示器激活按钮
  93. background: #fff;
  94. }
  95. /deep/ .el-carousel__container {
  96. height: 100%;
  97. }
  98. }
  99. .custom-indicator button {
  100. background-color: #fff;
  101. border: 1px solid #ccc;
  102. opacity: 0.7;
  103. }
  104. .custom-indicator button.is-active {
  105. background-color: #333;
  106. border-color: #333;
  107. opacity: 1;
  108. }
  109. </style>