BigSwiper.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <!-- 首页大的轮播图 -->
  3. <div class="swiper">
  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" 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. const nuxtApp = useNuxtApp();
  20. const axios = nuxtApp.$axios;
  21. let imagelist = useState("imageList", () => "")
  22. let lunbo = async () => {
  23. try {
  24. const response = await axios.get(`/web/getWebsiteArticlett?pageSize=${5}&level=${2}&placeid=${0}`);
  25. // console.log(response.data);
  26. imagelist.value = response.data;
  27. } catch (error) {
  28. console.error(error);
  29. }
  30. }
  31. onMounted(() => {
  32. lunbo()
  33. })
  34. </script>
  35. <style lang="less" scoped>
  36. .swiper {
  37. width: 720px;
  38. height: 405px;
  39. position: relative;
  40. img {
  41. width: 790px;
  42. height: 405px;
  43. }
  44. .text {
  45. display: inline-block;
  46. width: 790px;
  47. height: 60px;
  48. line-height: 60px;
  49. padding-left: 23px;
  50. box-sizing: border-box;
  51. position: absolute;
  52. bottom: 0;
  53. left: 0;
  54. font-family: Microsoft YaHei, Microsoft YaHei;
  55. font-weight: 400;
  56. font-size: 18px;
  57. color: #FFFFFF;
  58. background-color: rgba(0, 0, 0, 0.5);
  59. span {
  60. display: inline-block;
  61. width: 460px;
  62. height: 60px;
  63. white-space: nowrap;
  64. overflow: hidden;
  65. text-overflow: ellipsis;
  66. }
  67. }
  68. }
  69. .el-carousel {
  70. //指示器位置
  71. ::v-deep .el-carousel__indicators {
  72. left: unset;
  73. transform: unset;
  74. right: 3%;
  75. }
  76. // 未选中的指示器样式,设置为小圆圈
  77. ::v-deep .el-carousel__indicator:not(.is-active) button {
  78. width: 8px;
  79. height: 8px;
  80. border-radius: 50%;
  81. background-color: #ccc;
  82. }
  83. // 选中的指示器样式,设置为长条状
  84. ::v-deep .el-carousel__indicator.is-active button {
  85. width: 50px;
  86. height: 8px;
  87. border-radius: 4px;
  88. background-color: #fff;
  89. }
  90. }
  91. </style>