BigSwiper.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <div class="swiper" v-if="imagelist">
  3. <el-carousel :interval="5000" arrow="always" height="405px" indicator-class="custom-indicator"
  4. class="custom-carousel" @change="handleIndicatorChange">
  5. <el-carousel-item v-for="(item, index) in imagelist" :key="index">
  6. <NuxtLink :to="`/${item.pinyin}/${item.id}.html`"
  7. :title="item.title">
  8. <img :src="item.imgurl" :alt="item.title">
  9. <span>{{ item.title }}</span>
  10. </NuxtLink>
  11. </el-carousel-item>
  12. <template #indicator="{ index }">
  13. <button :class="{ 'active-indicator': currentIndex === index }">{{ index + 1 }}</button>
  14. </template>
  15. </el-carousel>
  16. </div>
  17. </template>
  18. <script setup>
  19. import { ElCarousel, ElCarouselItem } from 'element-plus'
  20. //获取焦点图数据 start---------------------------------------->
  21. const imagelist = ref("")
  22. async function getModelData1() {
  23. const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
  24. method: 'GET',
  25. query: {
  26. 'pageSize': 5,
  27. 'level': 2,
  28. 'placeid': 0,
  29. 'id':''
  30. },
  31. });
  32. if(mkdata.code == 200){
  33. imagelist.value = mkdata.data;
  34. }else{
  35. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  36. console.log("错误位置:获取首页轮播图")
  37. console.log("后端错误反馈:",mkdata.message)
  38. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  39. }
  40. }
  41. getModelData1()
  42. let currentIndex = ref(0)
  43. let handleIndicatorChange = (val) => {
  44. currentIndex.value = val
  45. }
  46. </script>
  47. <style lang="less" scoped>
  48. .swiper {
  49. width: 720px;
  50. height: 405px;
  51. position: relative;
  52. img {
  53. width: 720px;
  54. height: 405px;
  55. }
  56. span {
  57. display: inline-block;
  58. width: 720px;
  59. height: 118px;
  60. padding-top: 20px;
  61. padding-left: 23px;
  62. box-sizing: border-box;
  63. position: absolute;
  64. top: 0;
  65. left: 0;
  66. font-family: Source Han Sans, Source Han Sans;
  67. font-weight: 800;
  68. font-size: 24px;
  69. color: #FFFFFF;
  70. background: linear-gradient(to bottom, rgba(0, 0, 0, 1), rgba(0, 0, 0, 0));
  71. }
  72. }
  73. .el-carousel {
  74. // 左右箭头按钮
  75. .el-carousel__arrow--right :deep(.class-name),
  76. .el-carousel__arrow--left :deep(.class-name) {
  77. width: 68px;
  78. height: 68px;
  79. }
  80. //左右箭头图片
  81. /deep/.el-icon svg {
  82. height: 1em;
  83. width: 1em;
  84. background-color: transparent;
  85. }
  86. /deep/.el-carousel__arrow {
  87. border-radius: 0;
  88. background-color: transparent;
  89. }
  90. /deep/.el-carousel__arrow i {
  91. font-size: 68px !important;
  92. }
  93. /deep/ .el-carousel__indicators {
  94. // 指示器
  95. left: unset;
  96. transform: unset;
  97. right: 41%;
  98. }
  99. /deep/ .el-carousel__button {
  100. // 指示器按钮
  101. width: 20px;
  102. height: 20px;
  103. border-radius: 50%;
  104. border: none;
  105. opacity: 1;
  106. background-color: #FFFFFF;
  107. }
  108. /deep/ .is-active .el-carousel__button {
  109. // 指示器激活按钮
  110. background: #46D333;
  111. }
  112. /deep/ .el-carousel__container {
  113. height: 100%;
  114. }
  115. /deep/.custom-indicators {
  116. position: absolute;
  117. bottom: 10px;
  118. left: 50%;
  119. transform: translateX(-50%);
  120. }
  121. // 将指示器的所有样式都不显示
  122. // /deep/.el-carousel__indicators {
  123. // display: none;
  124. // }
  125. }
  126. </style>