swiper.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <div class="home-swiper">
  3. <el-carousel class="imgBox" :autoplay="false" v-if="swiperList">
  4. <el-carousel-item class="imgList" v-for="(item, index) in swiperList" :key="index"><el-image :src="item" alt="" class="swiper-img" /></el-carousel-item>
  5. </el-carousel>
  6. </div>
  7. </template>
  8. <script>
  9. import { loadIndexs } from '@/api/index.js';
  10. export default {
  11. data() {
  12. return {
  13. swiperList: []
  14. };
  15. },
  16. created() {
  17. this.getSwiperList();
  18. },
  19. methods: {
  20. getSwiperList() {
  21. let obj = this;
  22. console.log(obj);
  23. loadIndexs().then(res => {
  24. obj.swiperList = res.data.loop.split(',').map(e => {
  25. return obj.$store.state.www + e;
  26. });
  27. });
  28. }
  29. }
  30. };
  31. </script>
  32. <style lang="scss">
  33. .imgBox {
  34. .is-active {
  35. .el-carousel__button {
  36. background-color: #0165b5 !important;
  37. }
  38. }
  39. }
  40. .home-swiper {
  41. max-width: 1920px;
  42. min-width: 1080px;
  43. position: relative;
  44. padding-top: 40.37%;
  45. .imgBox {
  46. position: absolute;
  47. width: 100%;
  48. height: 100%;
  49. top: 0;
  50. left: 0;
  51. .imgList {
  52. width: 100%;
  53. height: 100%;
  54. }
  55. .el-carousel__container {
  56. height: 100%;
  57. }
  58. }
  59. .swiper-img {
  60. width: 100%;
  61. height: 100%;
  62. }
  63. }
  64. </style>