BigSwiper.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <!-- 首页大的轮播图 -->
  3. <div class="swiper">
  4. <el-carousel height="400px" v-if="imagelist">
  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" alt="">
  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. import { onMounted } from 'vue'
  19. //轮播图数据
  20. let imagelist = useState("imageList", () => "")
  21. async function getModelData1() {
  22. const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
  23. method: 'GET',
  24. query: {
  25. 'pageSize': 5,
  26. 'level': 2,
  27. 'placeid': 0,
  28. 'id':0,
  29. },
  30. });
  31. if(mkdata.code == 200){
  32. imagelist.value = mkdata.data;
  33. }else{
  34. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  35. console.log("错误位置:设置大标题")
  36. console.log("后端错误反馈:",mkdata.message)
  37. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  38. }
  39. }
  40. getModelData1()
  41. </script>
  42. <style lang="less" scoped>
  43. .swiper {
  44. width: 720px;
  45. height: 405px;
  46. position: relative;
  47. img {
  48. width: 790px;
  49. height: 405px;
  50. }
  51. .text {
  52. display: inline-block;
  53. width: 790px;
  54. height: 60px;
  55. line-height: 60px;
  56. padding-left: 23px;
  57. box-sizing: border-box;
  58. position: absolute;
  59. bottom: 0;
  60. left: 0;
  61. font-family: Microsoft YaHei, Microsoft YaHei;
  62. font-weight: 400;
  63. font-size: 18px;
  64. color: #FFFFFF;
  65. background-color: rgba(0, 0, 0, 0.5);
  66. span {
  67. display: inline-block;
  68. width: 460px;
  69. height: 60px;
  70. white-space: nowrap;
  71. overflow: hidden;
  72. text-overflow: ellipsis;
  73. }
  74. }
  75. }
  76. .el-carousel {
  77. //指示器位置
  78. ::v-deep .el-carousel__indicators {
  79. left: unset;
  80. transform: unset;
  81. right: 3%;
  82. }
  83. // 未选中的指示器样式,设置为小圆圈
  84. ::v-deep .el-carousel__indicator:not(.is-active) button {
  85. width: 8px;
  86. height: 8px;
  87. border-radius: 50%;
  88. background-color: #ccc;
  89. }
  90. // 选中的指示器样式,设置为长条状
  91. ::v-deep .el-carousel__indicator.is-active button {
  92. width: 50px;
  93. height: 8px;
  94. border-radius: 4px;
  95. background-color: #fff;
  96. }
  97. }
  98. </style>