SmallSwiperNmg.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <div class="swiper" v-if="imagelist.length>0">
  3. <el-carousel :interval="5000" height="405px" indicator-class="custom-indicator" @change="handleIndicatorChange">
  4. <el-carousel-item v-for="item in imagelist" :key="item">
  5. <NuxtLink :to="`/${item.pinyin}/${item.id}.html`" :title="item.title">
  6. <img :src="item.imgurl" :alt="item.title">
  7. <span class="swiper_dot1 dot1">{{ item.title }}</span>
  8. </NuxtLink>
  9. </el-carousel-item>
  10. </el-carousel>
  11. </div>
  12. </template>
  13. <script setup>
  14. import { ElCarousel, ElCarouselItem } from 'element-plus'
  15. //获取焦点图数据 start---------------------------------------->
  16. const imagelist = ref("")
  17. async function getModelData1() {
  18. const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
  19. method: 'GET',
  20. query: {
  21. 'imgnum': 5,
  22. 'textnum': 0,
  23. 'level': 2,
  24. 'placeid': 0,
  25. 'id': ''
  26. },
  27. });
  28. if (mkdata.code == 200) {
  29. imagelist.value = mkdata.data.img;
  30. } else {
  31. console.log("错误位置错误:获取首页轮播图", mkdata.message)
  32. }
  33. }
  34. getModelData1()
  35. let currentIndex = ref(0)
  36. let handleIndicatorChange = (val) => {
  37. currentIndex.value = val
  38. }
  39. //获取焦点图数据 end---------------------------------------->
  40. </script>
  41. <style lang="less" scoped>
  42. .dot1 {
  43. display: block;
  44. word-break: keep-all;
  45. white-space: nowrap;
  46. overflow: hidden;
  47. text-overflow: ellipsis;
  48. }
  49. .swiper {
  50. width: 100%;
  51. height: 405px;
  52. position: relative;
  53. img {
  54. width: 100%;
  55. height: 405px;
  56. }
  57. .swiper_dot1 {
  58. display: block;
  59. width: 100%;
  60. line-height: 60px;
  61. height: 60px;
  62. color: #fff;
  63. font-size: 24px;
  64. text-indent: 20px;
  65. position: absolute;
  66. bottom: 0;
  67. left: 0;
  68. z-index: 10;
  69. box-sizing: border-box;
  70. padding-right: 244px;
  71. background: rgba(0, 0, 0, .5);
  72. }
  73. }
  74. .el-carousel {
  75. /deep/.el-carousel__arrow i {
  76. font-size: 30px !important;
  77. }
  78. /deep/.el-carousel__arrow--left {
  79. left: 16px;
  80. width: 35px;
  81. height: 57px;
  82. color: #616358;
  83. background: #dcdedc;
  84. position: absolute;
  85. left: 0px;
  86. border: none;
  87. border-radius: 0;
  88. }
  89. /deep/.el-carousel__arrow--right {
  90. right: 16px;
  91. width: 35px;
  92. height: 57px;
  93. color: #616358;
  94. background: #dcdedc;
  95. position: absolute;
  96. right: 0;
  97. border: none;
  98. border-radius: 0;
  99. }
  100. /deep/ .el-carousel__indicators {
  101. // 指示器
  102. left: unset;
  103. transform: unset;
  104. right: 10px;
  105. bottom: 11px;
  106. }
  107. /deep/ .el-carousel__button {
  108. // 指示器按钮
  109. width: 10px;
  110. height: 10px;
  111. border: none;
  112. border-radius: 5px;
  113. background: #ccc;
  114. opacity: 1;
  115. }
  116. /deep/ .is-active .el-carousel__button {
  117. // 指示器激活按钮
  118. background: #fff;
  119. width: 58px;
  120. opacity: 1;
  121. }
  122. /deep/ .el-carousel__container {
  123. height: 100%;
  124. }
  125. }
  126. .custom-indicator button {
  127. background-color: #fff;
  128. opacity: 1;
  129. width: 8px;
  130. height: 8px;
  131. }
  132. .custom-indicator button.is-active {
  133. background-color: #DD7D18;
  134. width: 58px;
  135. opacity: 1;
  136. }
  137. </style>