BigSwiper.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <!-- 首页大的轮播图 -->
  3. <div class="swiper" v-if="imagelist">
  4. <el-carousel height="400px">
  5. <el-carousel-item v-for="(item, index) in imagelist" :key="index">
  6. <NuxtLink :to="`/newsDetail/${item.id}`" target="_blank">
  7. <img :src="item.imgurl">
  8. <div class="text">
  9. <span>{{ item.title }}</span>
  10. </div>
  11. </NuxtLink>
  12. </el-carousel-item>
  13. </el-carousel>
  14. </div>
  15. </template>
  16. <script setup>
  17. import { ElCarousel, ElCarouselItem } from 'element-plus'
  18. //获取焦点图数据 start---------------------------------------->
  19. const imagelist = ref("")
  20. async function getModelData1() {
  21. const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
  22. method: 'GET',
  23. query: {
  24. 'pageSize': 5,
  25. 'level': 2,
  26. 'placeid': 0,
  27. 'id':''
  28. },
  29. });
  30. if(mkdata.code == 200){
  31. imagelist.value = mkdata.data;
  32. }else{
  33. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  34. console.log("错误位置:获取首页轮播图")
  35. console.log("后端错误反馈:",mkdata.message)
  36. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  37. }
  38. }
  39. getModelData1()
  40. let currentIndex = ref(0)
  41. let handleIndicatorChange = (val) => {
  42. currentIndex.value = val
  43. }
  44. </script>
  45. <style lang="less" scoped>
  46. .swiper {
  47. width: 720px;
  48. height: 405px;
  49. position: relative;
  50. img {
  51. width: 790px;
  52. height: 405px;
  53. }
  54. .text {
  55. display: inline-block;
  56. width: 790px;
  57. height: 60px;
  58. line-height: 60px;
  59. padding-left: 23px;
  60. box-sizing: border-box;
  61. position: absolute;
  62. bottom: 0;
  63. left: 0;
  64. font-family: Microsoft YaHei, Microsoft YaHei;
  65. font-weight: 400;
  66. font-size: 18px;
  67. color: #FFFFFF;
  68. // background-color: #eee;
  69. span {
  70. display: inline-block;
  71. width: 460px;
  72. height: 60px;
  73. white-space: nowrap;
  74. overflow: hidden;
  75. text-overflow: ellipsis;
  76. font-size: 24px;
  77. position: absolute;
  78. z-index: 50;
  79. }
  80. }
  81. .text:after {
  82. background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.7));
  83. bottom: 0;
  84. content: "";
  85. display: block;
  86. height: 68px;
  87. left: 0;
  88. position: absolute;
  89. width: 100%;
  90. z-index: 44;
  91. }
  92. }
  93. .el-carousel {
  94. // 指示器位置
  95. ::v-deep .el-carousel__indicators {
  96. left: unset;
  97. transform: unset;
  98. right: 1%;
  99. }
  100. // 未选中的指示器样式,设置为小圆圈
  101. ::v-deep .el-carousel__indicator:not(.is-active) button {
  102. width: 10px;
  103. height: 10px;
  104. border-radius: 50%;
  105. background-color: #fff;
  106. }
  107. // 选中的指示器样式,设置为长条状
  108. ::v-deep .el-carousel__indicator.is-active button {
  109. width: 10px;
  110. height: 10px;
  111. border-radius: 50%;
  112. background-color: #dd7d18;
  113. }
  114. }
  115. </style>